File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String Pool" Watch "String Pool" New topic

String Pool

deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
hi all,
i have got a doubt. & that is
when are the objects in the string pool garbage collected?
for example
String a = "literal_1"; //1
String b = "literal_2"; //2
a = null; //3
b = null; //4
whether the literals in line 1 & 2 are eligible for gc after line 4 has executed.
i feel they are not eligible for gc since they are in string pool. but that raises my doubt that when they will be gced.because if i keep on creating literals then my program will run out of memory if gc won't claim the string pool?
thanx in advance

I agree. Here's the link:
subject: String Pool
It's not a secret anymore!