r/learnjava • u/BerserkGamer_YT • Aug 06 '21
Doubts regarding the return statements
can someone explain me why this method returns a Boolean without me actually using a "return boolean" statement in there?
public boolean doesArrayContainThisValue(int searchValue) {
boolean valueInArray = false;
for(int i = 0; i < arraySize; i++){
if(theArray[i]==searchValue){
valueInArray = true;
}
3
Upvotes
6
u/CelticHades Aug 06 '21
Isn't it giving an error? It must be giving error for lack of return statement