【发布时间】:2022-11-30 15:43:43
【问题描述】:
我正在准备 Oracle 认证考试,所以你能解释一下 10!=2 是如何变得真实和编译错误的吗,我在下面提到了一个小程序。 10!=2 :为什么它是真的 "Hello "+10!=2 : 为什么是编译时错误
公开课 Demo1 {
public static void main(String[] args1) {
System.out.println(10!=2); //Output is True
System.out.println("Hello "+10!=2); //Compile Time Error
}
}
【问题讨论】:
-
在第二个语句中,由于字符串连接,您正在执行“Hello 10”!= 2。尝试“你好” + (10 != 2)
-
谢谢你明白了
标签: java spring-boot jsp