mercredi 22 juillet 2015

return Statement from each branching

Some times I found some compilation error like this -

public static boolean returnTrueFalse(){

   if(someConditions) return true;

   if(someConditions){
      //do something
      return true;
   }

   if(someConditions){
      //do something
      return false;
   }

   //GOT A COMPILATION ERROR HERE


}

In above situation we got a compilation error at the commented portion saying - missing return statement. So how can we avoid this situation?

Thanks

Aucun commentaire:

Enregistrer un commentaire