gkumar7 :
Why does this not compile (tried with java 8 and java 10)? It yields a missing return statement error.
public class CompilerIssue {
public boolean run() {
throwIAE();
// Missing return statement
}
public void throwIAE() {
throw new IllegalStateException("error");
}
}
DwB :
The java compiler does not know that the throwIAE
will always throw an exception so it assumes that you will eventually reach the end of the run
method and, when that happens, a return value is required.