java - return Statement from each branching -
this question has answer here:
- java error missing return statment 6 answers
some times found compilation error -
public static boolean returntruefalse(){ if(someconditions) return true; if(someconditions){ //do return true; } if(someconditions){ //do return false; } //got compilation error here }
in above situation got compilation error @ commented portion saying - missing return statement
. how can avoid situation?
thanks
well, message of compile error pretty clear : code must encounter return statement of every possible execution path because method has non-void return type. add return statement last case, or throw exception if should not reach state in normal execution.
Comments
Post a Comment