java - error: bad operand types for binary operator '&&' -


not sure wrong here line wrong.

if((board[z][i] = 1) && (board[z][i++] = 1) && (board[z++][i] = 1)){ 

here whole code not finished:

public class solution {   static void nextmove(int player, int [][] board){  }      public static void main(string[] args) {     scanner in = new scanner(system.in);     int player;     int board[][] = new int[8][8];      //if player 1, i'm first player.     //if player 2, i'm second player.     player = in.nextint();      //read board now. board 8x8 array filled 1 or 0.   for(int z = 0; z < 8; z++){       for(int = 0; < 8; i++) {           board[(z)][(i)] = in.nextint();          }   }for(int z = 0; z < 8; z++){        for(int = 0; < 8; i++) {            if((board[z][i] = 1) && (board[z][i++] = 1) && (board[z++][i] = 1)){                system.out.print(z + " " + i);         }     }   }     nextmove(player,board);  } } 

you need use relational operator == instead of =. each of 3 sub-statements within parentheses of if statement should represent boolean. in java, = used assign value , == used check equality. therefore, must change if statement to:

if((board[z][i] == 1) && (board[z][i++] == 1) && (board[z++][i] == 1)){ 

also, rather incrementing z , 1 (because doing part of loop), maybe make i++ --> + 1 , z++ --> z + 1.

hope helps!


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -