public class Test {
public static void main(String[] args){
System.out.println(new Test().test());
}
public int test(){
int a=0;
try{
a=1;
execute();
System.out.println(1);
return a;
}catch(RuntimeException e){
a=2;
System.out.println(2);
return a;
}catch(Exception e){
a=3;
System.out.println(3);
return a;
}finally{
a=4;
System.out.println(4);
}
}
public void execute() throws ArrayIndexOutOfBoundsException{
throw new ArrayIndexOutOfBoundsException();
}
}
结果为:2 4 2