The statement on Line 2 will never execute but the compiler doesn't complain:
class Test {
public static void main(String[] args) throws Exception {
throwE();
// throw new Exception(); // Line 1
doStuff(); // Line 2
}
static void throwE() throws Exception {
System.out.println("Throwing an Exception");
throw new Exception();
// doStuff(); // Line 3
}
static void doStuff(){ System.out.println("Doing stuff"); }
}
On the other hand, uncommenting either Line 1 or Line 3 leads to the 'unreachable statement' compile-time error.
I wonder why the compiler is so inconsistent...