java测试题目

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("相等");
     }
}

猜你喜欢

转载自blog.csdn.net/weixin_42797483/article/details/132524613