[英]Bad operand types for binary operator “<”
Getting a bad operand types for binary operator ">"
, bad operand types for binary operator ">"
获取bad operand types for binary operator ">"
,
first type: boolean; 第一种类型:布尔值; second type: int.
第二种类型:整数。
In this line: 在这一行:
if( 0 < r < getNumberOfRows()&& 0 < c < getNumberOfColumns());
The getNumberOfRows()
returns an int value, and r
is declared as an int
right above the if
statement. getNumberOfRows()
返回一个int值,并且r
在if
语句上方声明为int
。 No idea what is wrong. 不知道怎么了。
public int numberAdjacent(int row, int column)
{
int count = 0;
int r = row;
int c = column;
if( 0 < r < getNumberOfRows()&& 0 < c < getNumberOfColumns()){
if(map[r+1][c+1]) {
count++;
}
Java does not have a a < b < c
construct to check if b
is between a
and c
. Java没有
a < b < c
构造来检查b
是否在a
和c
之间。 Instead, you need to break it into two separate comparisons, a < b
and b < c
. 相反,您需要将其分为两个独立的比较,
a < b
和b < c
。
In your example it would look like; 在您的示例中,它看起来像;
if( 0 < r && r < getNumberOfRows() && 0 < c && c < getNumberOfColumns() ) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.