When I run the following java code, I get the output as "ACDF". Could someone please explain how the runtime exception thrown in innermost catch block is handled? (I was expecting it to be handled in the block where "E" is being appended to result string variable)
public class HelloWorld {
public static String someFunction() {
String result = "";
String str = null;
try {
try {
try {
result += "A";
str.length();
result += "B";
} catch (NullPointerException e) {
result += "C";
throw new RuntimeException(); // where this one goes????
} finally {
result += "D";
throw new Exception();
}
} catch (RuntimeException e) {
result += "E";
}
} catch (Exception e) {
result += "F";
}
return result;
}
public static void main(String[] args) {
System.out.println(someFunction());
}
}