异常处理
class ExceptionDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
int x, y, z,c;
int[] a = {1,2};
try{
x = 16;
y=0;
z = x / y;
System.out.println("x/y =" + z);
c = a[2];
System.out.println("Array =" + c);
/* }catch(ArithmeticException e){
System.out.println("Exception ArithmeticException");
}*/
}catch(Exception e) {
System.out.println("Exception : " + e.toString());
/*
* System.out.println("Exception Array Index Out Of Bounds");
*/
}finally {
System.out.println("End of programming");
}
System.out.println("End");
}
}