Hi guys,
I'm studing the
String chapter and written some code that is not giving the result I expect. What I understood is that when you create a String, if it already present in the pool then that is assigned to your reference.
This is my
test code:
I expected s1==s2 to return true, because both the Strings contains "abcdef" so I thought the JVM assigned s1 and s2 to the same String in the pool, but this doesn't seem correct. This is the output of the execution:
s1 = abcdef
s2 = abcdef
s1 and s2 has the same value
shouldn't print this
Can someone help me clarifying this point?
Thanks a lot folks!
Mattia