public class Test2 {
public static void main(String args[]) {
System.out.println(method());
}
public static int method() {
try {
throw new Exception();
return 1;
} catch (Exception e) {
return 2;
} finally {
return 3;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这个问题中try块有return语句并抛出异常...它的输出是COMPILER ERROR ....
我们知道finally块会覆盖try/catch块中的return或exception语句...但是这个问题在try块中都有...为什么输出是错误的?