package yichang;
import java.util.InputMismatchException;
public class TryCatchFinally {
public static void main(String[] args) {
try{
int num1 = 12;
int num2 = 0;
System.out.println("两个数的商为:"+num1/num2);
}catch (InputMismatchException ex){//EXception一般能检测基本的异常,现在用InputMismatchException测试
System.out.println("亲爱的用户,您的程序出现错误");
}finally{
System.out.println("无论程序是否有异常,本语句一定执行");
}//try-catch-finally:用来告诉客户输入错误,不是用来告诉程序员程序错误
System.out.println("test");//程序出错,不会执行这条语句
}
}