Page No: 316
String singleString = "hello world";
String oneLine = "hello " + "world";
System.out.println(singleString == oneLine);
Both print false. Concatenation is just like calling a method and
results in a new String.
Page No: 317
15: String first = "rat" + 1;
16: String second = "r" + "a" + "t" + "1";
18: System.out.println(first == second);
19: System.out.println(first == second.intern());
On line 15, we have a compile-time constant that automatically gets
placed in the string pool as "rat1". On line 16, we have a more
complicated expression that is also a compile-time constant.
Therefore, first and second share the same string pool reference. This
makes line 18 and 19 print true.
You have discussed the same topics, but the logic is quite contradictory.