if() 语句括号中为比较表达式,返回值要么是 true,要么是 false,if(x=y) 是将 y 赋值给 x,但是数据类型是 int 类型的,编译不能通过。
public class IfTest{
public static void main(String[] args){
int x=3;
int y=1;
if(x=y)
System.out.println("不相等");
else
System.out.println("相等");
}
}