以下是一道面试题:
public class InterviewQuestion {
/**
* what is return value of this method
* you can test yourself before running program
* @return
*/
public static int test1() {
int x = 0;
try {
x = 1;
return x;
} finally {
x = 2;
}
}
public static void main(String[] args) {
System.out.println(test1());
}
}
具体原理参考链接: