Reputation: 1
I have an if statement that is throwing "invalid assignment operator" in Java (on both lines). I can't figure out what I'm doing wrong here. Any help is appreciated:
if ((row >= 0) && (row < this.rows) && ((col – 1) >= 0) && ((col – 1) < this.cols)) {
nbrNeighbors += grid[row][col – 1];
}
Upvotes: 0
Views: 99
Reputation: 131
I've checked your example in my IDE and the only thing that seems wrong for me is your minus(-) character:
Illegal character (U+2013)
.
Try to paste my version:
if ((row >= 0) && (row < this.rows) && ((col - 1) >= 0) && ((col - 1) < this.cols)) {
nbrNeighbors += grid[row][col - 1];
}
Upvotes: 0
Reputation: 8481
It looks like you are using a wrong character for the minus operation: – ('EN DASH' (U+2013)). Try to use - instead.
Upvotes: 1