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); } } } }