Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Originally posted by Ibrahim Hashimi:
I need some help refreshing my memory what is the method to ensure no duplicates in the string literal pool.
Thanks.
SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Mag
Originally posted by Robert Mmmo:
Ibrahim,
I think you are wrong..
after line 2 you have two references to String objects which are not referring to null
when you say s1 = s1.intern()
s1 references to the literal "test"
and according to my knowledge that's not null
Question what raises is when will s1 be eligble for gc ??
i think s1 will never be eligble for gc(during the scoop of the program) this because it refers now to the literal "test" which is stored on the heap
correct me when im wrong..
Robert
[ May 10, 2002: Message edited by: Robert Mmmo ]
SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Robert, reread my comments paying careful attention to the difference between the heap and the literal pool. Remember, only objects on the heap are garbage collected.Originally posted by Robert Ziel:
Thomas,
why is s1 eligle for gc
s1 contains the reference for the unique poolString so i would think not null
so not eligble for gc
could you tell me where i went wrong..??
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |