Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

What does String intern() method do?

Category: Java

When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String
object is returned.
This method always return a String that has the same contents as this string, but is guaranteed to be from a pool of unique strings.

Leave a Reply

Your email address will not be published. Required fields are marked *