Java的异常类 Li.040
Java 的异常类 异常的体系 Throwable Error Exception RuntimeException 如果程序没有处理异常, JVM 自行处理, 把异常的名称和信息, 打印在控制台上. 异常的2种处理方式 try catch finally try catch try catch finally try finally throws public class Demo1_Exception { public static void main(String[] args) { Demo1 demo1 = new Demo1(); int x; try{ x = demo1.div(10,0); } catch (ArithmeticException e){ System.out.println(e.getClass()); System.out.println("test"); }finally { System.out.println("最后执行了吗"); } } } class Demo1 { public int div (int a, int b){ return a/b; } } public class Demo2_Exception { public static void main(String[] args) { int a = 0; int b = 10; int[] arr = {1, 2, 3}; int x ; arr = null; try { // x = b / a; System....