Well this is in additon to one of the question asked previously. I wanted to know if u do as following. String s = new String("Java"); s.intern(); String s = "Java"; s==s1 still returns false. why!. cause if you have two strings like, String s1="java"; String s2="java"; s1==s2 will always return true due to this string being in the pool not in the heap. so what is the significance of intern() method. Jennifer.
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
posted
0
because invoking intern on s does not reassign the reference hold by s to the reference now contained in the pool. try doing this and it works s = s.intern(); HIH ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform