Thirdware Technologies Interview Question
Software Engineer / DevelopersIntern basically manages a pool of string in case u add a string which is not in the pool it will get added else both the strings will point to same string. So using intern comparison of 2 string become efficient than using str1.equals(str2)
intern() method of String class returns canonical representation for the string object from string pool.
- prabhat January 02, 2011so even if two string object have same value and return false on == comparision
string1.intern()==string2.intern() returns true