android_异常

 

  
  
  
  
  1. public class MyTest{ 
  2.     private static String name; 
  3.     private static int n1,n2; 
  4.     public static void main(String args[]){ 
  5.         try
  6.                name="My name"
  7.                n1=Integer.parseInt(args[0]); 
  8.                n2=Integer.parseInt(args[1]); 
  9.                System.out.println(name); 
  10.                System.out.println("divie"+n1/n2); 
  11.             } 
  12.             catch(ArithmeticException e){ 
  13.                 System.out.println("error"); 
  14.                 throw new Exception("pao chu yi chang"); 
  15.                 } 
  16.                 //finally 必然会执行 
  17.                 finally
  18.                     System.out.println("finally"); 
  19.                     } 
  20.              
  21.         } 
  22.     } 

 

你可能感兴趣的:(android,异常)