Java – Can’t return inside an if statement, using boolean

booleanfor-loopjavareturn

I'm trying to make a boolean method, but it's not recognizing I have a return statement. What should I do?

public boolean isThreeKind( int rankHist[]) {
  for (int i=0;i<=13;i++){
      if (rankHist[i]>=3){
          return true;
      }else{
          return false;
      }

  }
}

Best Answer

Your code does not make sense. There is no point in having a loop if you're always going to run the code inside the loop exactly once. I think you must have misunderstood. What are you trying to do?