this method must return a result of type boolean, java

前端 未结 5 1273
孤独总比滥情好
孤独总比滥情好 2020-11-28 16:04
 public boolean Winner() {
    for (int z = 0; z < 3; z++) {
            if (board[z] != null && board[z] == board[z+3] && board[z] == board[z+6]
         


        
5条回答
  •  独厮守ぢ
    2020-11-28 16:57

    The compiler is not aware that at least one of the loops will be executed. It takes into account all the possibilities of the execution and one of them is that neither of the loops will be executed and in that case there is no return statement. So insert a return statement out of the loops as well.

提交回复
热议问题