package daima;
import java.util.*;
public class ExceptionTest {
public static void main(String[] args) {
     int a,b,s =-1;
     Scanner ExceptionTest=new Scanner(System.in);
     System.out.println("请输入一个整数");
     a=ExceptionTest.nextInt();
     System.out.println("请再输入一个整数");
     b=ExceptionTest.nextInt();
     try{
          s=a/b;
     }
     catch(Exception e){
     System.out.println("分母为0,异常!");
     }finally{
       if(s!=-1){
       System.out.println(s);
     }
     }
     }
     }

  

posted on 2019-06-19 12:43  卢思林  阅读(143)  评论(0编辑  收藏  举报