String s4 "hellohello" - .
- true :
System.out.println("hellohello" == s4);
s6 , s2. "hellohello" s6 . - false :
System.out.println("hellohello" == s6);
But if you declare it s2as final , which makes the constant a s2constant, you get trueinstead of falsethe string System.out.println("hellohello" == s6);, because now the compiler can put the string s6, since it depends on constant values, and the links to "hellohello" s6will be equal to each other.
user784540
source
share