java - return Statement from each branching -


this question has answer here:

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

Popular posts from this blog

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -