用代码证明,在try中写了return,后面又写了finally,是先执行return还是先执行fianlly?
class Demo3
{
public static void main(String[] args){
int a =10;
int b = 0;
System.out.println(sum(a,b));//2
}
public static int sum(int a ,int b){
try{
int c =a/b;
int i = 0;
return i;
}catch(Exception e ){
int i =1;
return i;
}finally{
int i =2;
return i;
}
}
} |
|