Home > Mobile >  Why do i get bad operand type for binary type ' !=' first type char, second type <nullt
Why do i get bad operand type for binary type ' !=' first type char, second type <nullt

Time:04-15

if(grid[row][col] != null){
               throw new IllegalMoveException();
           }

its seeing if the index of the 2d-array is null or not i really dont get it please help!!!! Thanks

CodePudding user response:

Because your grid variable's type is an array of primitives (char[][]), and primitives cannot be null. null is short for 'null pointer' - it is not identical to 0, nor is it identical to the NULL character (which is '\0', or just 0 casting to a char).

  • Related