The string property that you need to assign after calling this method, let's take an example, even if:
String S1= "Hello"; S1.concat("World");
and if you print the value of S1, it will print only "Hello". but if you write like this:
S1=S1.concat(" World");
then he will print "Hello World".
Similarly, you need to assign a value as:
s1=s1.intern(); s2=s2.intern();
and if you compare s1 == s2, it will return the true value, but, say:
String s3=s1.intern(); String s4=s2.intern();
and if you compare s3 == s4, then its true, but (s3 == s1) and (s4 == s2) will be false.
source share