Wednesday 18 November 2015

What does String intern() method do

The java string intern() method returns the interned string. It returns the canonical representation of string. It can be used to return string from pool memory, if it is created by new keyword.
public String intern()


Example:

Advantage: To get the reference of String constant pool object

No comments:

Post a Comment