/*
* 嵌套try_catch_finally示例
* @author gyw
* */
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;
public class MyTry_Catch_Finally2 {
public static void main(String[] args) {
int x, y, z;
String s1, s2;
System.out.println("请输入两个整数 : ");
//对应输入输出异常
try {
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
s1 = br.readLine();
s2 = br.readLine();
//对应数据格式异常
try {
x = Integer.parseInt(s1);
y = Integer.parseInt(s2);
//对应数学运算异常
try {
z = x / y;
System.out.println("两数相除的结果是 : " + z);
} catch(ArithmeticException e) {
System.out.println(e.getMessage() + "\n数学运算异常!!!");
} finally {
System.out.println("运算完毕 !!!");
}
} catch(NumberFormatException e) {
System.out.println("你输入的数据不正确,请重新输入 !!!");
}
} catch(IOException e) {
System.out.println("输入输出异常!!!");
} finally {
System.out.println("结束 !!!");
}
}
}