Relative Content

Tag Archive for javaexceptionjava-8

Java compiling error when line not reached rule

public static IOException method() { try { return new IOException(); } catch(FileNotFoundException e) { return new FileNotFoundException(); } } This will not compile, because FileNotFoundException block will never be reached. However, this will compile, although ClassCastException block will never be reached. Why this compiles and in first example not? static void print() { try { […]