Java - Looping 2d Array to find index of a value not working

后端 未结 2 892
孤街浪徒
孤街浪徒 2021-01-19 23:34

I know I\'m making an error somewhere in this code, but I can\'t figure it out. The player1.getId(); returns a value of 1 just so you are aware. I\'m trying to print the i

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-19 23:48

    The condition is true here (if player1.getId() == 1):

    if(grid[i][j] == player1.getId());

    But the code contains a logical error: a group of operators here - the empty operator ; and it will be executed...

    currentX and currentY always will be equals the length of the array.

    currentX = grid.length;
    currentY = grid[0].length;
    

提交回复
热议问题