package IO;
import java.util.Scanner;
import java.util.InputMismatchException;
public class Z5 {
public static void main(String[] args) {
try{
Scanner input= new Scanner(System.in);
System.out.println("请输入被除数");
int a =input.nextInt();
System.out.println("请输入被除数");
int b =input.nextInt();
int result =a/b;
System.out.println(result);
return;
}catch(InputMismatchException e){
System.out.println("输入类型不匹配");
}catch(ArithmeticException e){
System.out.println("除数不能为0");
} finally{
System.out.println("这就能运行啦");
}
}
}
加入try catch运行结果: