本人新手看一段代码不解 望大侠帮助public class TryCatchFinally{
static void proc(int sel){
System.out.println(“In situation ”+sel);
try{
if(sel==0){
System.out.println(“No exception caught.”);
return; //System.exit(0);
}else if(sel==1){
int i=0;
int j=4/i;
}else if(sel==2){
int iArray[]= new int [4];
iArray[4]=10;
}
}catch(ArithmeticException e){
System.out.println(“Catch:”+e);
}catch(ArrayIndexOutOfBoundsException e){
System.out.println(“Catch:”+e.getMessage());
}catch(Exception e){
System.out.println(“Will not be excecuted”);
}finally{
System.out.println(“In proc finally”);
}
}//end procpublic static void main(String args[]){
proc(0);
proc(1);
proc(2);可以用教学的方式教我一遍吗?
谢谢!
static void proc(int sel){
System.out.println(“In situation ”+sel);
try{
if(sel==0){
System.out.println(“No exception caught.”);
return; //System.exit(0);
}else if(sel==1){
int i=0;
int j=4/i;
}else if(sel==2){
int iArray[]= new int [4];
iArray[4]=10;
}
}catch(ArithmeticException e){
System.out.println(“Catch:”+e);
}catch(ArrayIndexOutOfBoundsException e){
System.out.println(“Catch:”+e.getMessage());
}catch(Exception e){
System.out.println(“Will not be excecuted”);
}finally{
System.out.println(“In proc finally”);
}
}//end procpublic static void main(String args[]){
proc(0);
proc(1);
proc(2);可以用教学的方式教我一遍吗?
谢谢!
int j=4/i;
这是什么啊?故意制造除零异常?