String s9 = "hello"+"world";
String s10 = "helloworld";
System.out.println(s9==s10);
String s11 = s4+"world";
System.out.println(s10==s11);
s10与s11不同的原理是什么??
String s9 = "hello"+"world";
String s10 = "helloworld";
System.out.println(s9==s10);
String s11 = s4+"world";
System.out.println(s10==s11);
s10与s11不同的原理是什么??
s4在哪里定义的。如果s4不是在程序编译的时候确定的,那么它不在常量池中,不是一个对象引用,所以==返回false。要比较字符串字面值,应该用equals