Why does my code work, when I use " in the following code:
for(int i=0;i<7;i++){
if(grid[row][i]!=0){
if(player == "yellow"){
grid[row][i-1] = 'y';
}
else if(player == "red"){
grid[row][i-1] = 'r';
}
}
}
But don't work, when I use ' in the following code:
for(int i=0;i<7;i++){
if(grid[row][i]!=0){
if(player == 'yellow'){
grid[row][i-1] = 'y';
}
else if(player == 'red'){
grid[row][i-1] = 'r';
}
}
}
It is always saying, "Invalid character constant".
- grid is a 2 dimensional char variable
- row is an interger
- player is the super class (window) protected and in the constructor of the super class occupied with the value yellow:
protected String player;
public window() {
player = "yellow";
}