basically intern of course is useful only for String object as the String literals are automatically interned.
A part from that, the use of intern to be meaningful must be done at the same time the object it's created.
example:
Code: Select all
String str1 = "Indeed";
String str = new String("Indeed").intern();
System.out.println(str1==str);
Let's pass this OCA exam.