mardi 1 septembre 2020

Why can't the boolean method see the return statement? [closed]

Sorry for the simple question but I couldn't search it online. I'm making a method (returns boolean) to check if two words are the same. in the end, I add an if statement, like so:

if (word1 == word2) {
  return true;
}
else {
  return false;
}

but there is still an error that says Missing return statement. Why can't the method read the return statement I added in the conditional? And how to fix that?

thanks in advance

Aucun commentaire:

Enregistrer un commentaire