简体   繁体   English

无效赋值运算符错误 >= Java

[英]Invalid Assignment Operator Error >= Java

I have an if statement that is throwing "invalid assignment operator" in Java (on both lines).我有一个 if 语句在 Java 中抛出“无效的赋值运算符”(在两行上)。 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]; 
}

It looks like you are using a wrong character for the minus operation: – ('EN DASH' (U+2013)).看起来您在减号运算中使用了错误的字符:– ('EN DASH' (U+2013))。 Try to use - instead.尝试使用 - 代替。

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) .我已经在我的 IDE 中检查了您的示例,对我来说唯一似乎错误的是您的减号(-)字符: 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]; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM