动手动脑一:
请阅读并运行AboutException.java示例
1 import javax.swing.*; 2 3 class AboutException { 4 public static void main(String[] a) 5 { 6 int i=1, j=0, k; 7 k=i/j; 8 9 10 try 11 { 12 13 k = i/j; // Causes division-by-zero exception 14 //throw new Exception("Hello.Exception!"); 15 } 16 17 catch ( ArithmeticException e) 18 { 19 System.out.println("被0除. "+ e.getMessage()); 20 } 21 22 catch (Exception e) 23 { 24 if (e instanceof ArithmeticException) 25 System.out.println("被0除"); 26 else 27 { 28 System.out.println(e.getMessage()); 29 30 } 31 } 32 33 34 finally 35 { 36 JOptionPane.showConfirmDialog(null,"OK"); 37 } 38 39 } 40 }