-1
public class Main {
public static void main(String[] args) {
System.out.println("Normal: " + testNormal());
System.out.println("Exception: " + testException());
}
public static int testNormal() {
try {
// no exception
return 0;
} catch (Exception e) {
System.out.println("[normal] Exception caught");
} finally {
System.out.println("[normal] Finally");
}
System.out.println("[normal] Rest of code");
return -1;
}
public static int testException() {
try {
throw new Exception();
} catch (Exception e) {
System.out.println("[except] Exception caught");
} finally {
System.out.println("[except] Finally");
}
System.out.println("[except] Rest of code");
return -1;
}
}
爲什麼「[normal]其餘代碼」不能執行和「[except]其餘代碼」不能執行?請解釋。解釋代碼執行的差異
作業的哪部分你不明白? –
你覺得'返回0;'是做什麼的? – Savior
''[except]其餘代碼正在執行。 – Savior