How do I make this work? It says that I need to add a return statement but I have one.
public boolean clockFactCheck(int a, int b){
for (int i = 0; i <= 276; i++){
for (int h = 0; h <= 55; h++){
if (a == i + 186 && b == h + 133){
return true;
} else {
return false;
}
}
}
}
The code provided may not reach one of the
returns for any inputa,band that’s what the compiler is complaining about.Actually in your case the
if-elsewill be reached with the very first iteration – unfortunately something which the compiler cannot deduce. Therefore, it goes the save way and issues this error.Comment: Therefore, in your loop seems not to make much sense since it will not iterate at all but stop within the first iteration
i==0andh==0. Did you meant to code something like that?