Hi ,yes should have been more specific.i wanted the purpose of String intern() method.as understand from the discussion it is required for removing duplicates.
String s="hello".concat("world");
String s2=s.intern();
System.out.println(s==s2);
In the above program, seeing the first line an new instance is created in heap,but not in SCP.
in the second line, the intern method creates an instance in the SCP but returns the same reference s;
so if add few more lines of code,
String s="hello".concat("world");
String s2=s.intern();
String s3="helloworld";
System.out.println(s==s2);//true
System.out.println(s==s3);//true
System.out.println(s2==s3);//true
so here should we understand it as the reference s is pointing to both the instances one in heap another one is SCP?