public MyObject method1() {
boolean someBoolean = true;
MyObject obj = ...;
if(!someBoolean) method1();
else return obj;
// flow should never come to this statement, but compiler requires this return. why?
return null;
}
why does the java compiler require the final return statement?
-Prasanna
If
!someBoolean, thenmethod1is called, but nothing is returned. So flow totally could end up at that last statement.