In i) only one String object is created. This object will be placed in the String constant pool.
In ii) two objects are created. Object one- String constant "Hello" to be placed in the String constant pool, Object two- String object with value "abc"
Do this after the two statements add the statement below and see the output
Reason- All reference variables refer to the same "Hello" string in the String constant pool.
int hashCode() - returns Object ID number(may not be always unique)
Now change the value of s2 to "Hellllo" and the output is-
69609650 69609650 -1824599884
Hope this helps!!
