How System.out.println(s1==s3.intern()); //return true? [closed]

Interning is making identical immutable objects hold the same reference to save memory. When s3 is interned, it is set to point to s1 from the inter pool(as it is a literal it is added there readily).

Since they have the same reference, == returns true.

Leave a Comment