String a = "abc";
String b = a.substring(1);
b.intern();
String c = "bc";
System.out.println(b == c);
The question might be foolish as intern has no major usage here, still I am confused about the fact, why does b == c
results true
.
When
String b = a.substring(1)
is executed, String b
references to object having "bc"
Does b.intern
create the literal "bc"
in String Constant pool, even if it does, how come b==c
result in true
?