Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

question about the java doc of String.intern() method

807588Mar 29 2009 — edited Mar 30 2009
hi all, my native language is not english, and i have a problem when reading the java doc of String.intern() method. the following text is extract from the documentation:

-----------------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------------

i just don't know the "a reference to this String object is returned" part, does the "the reference to this String" means the string that the java keyword "this" represents or the string newly add to the string pool?

eg,
String s=new String("abc");  //create a string
s.intern();  //add s to the string pool, and return what? s itself or the string just added to string pool?
greate thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2009
Added on Mar 29 2009
5 comments
584 views