A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
Programmer Certification (SCJP/OCPJP)
String object : Garbage Collection
Joined: Dec 05, 2003
Nov 24, 2004 10:54:00
when we have :-
s1 = new String("ABCDEFG");
I understand, there are two objects being created :-
(1)"ABCDEFG" -with no reference
(2)Second object "ABCDEFG" with a reference s1.
Say if the Garbage Collector runs,then does object(1)above ("ABCDEFG"- with no reference), gets garbage collected???
Joined: Mar 13, 2004
Nov 24, 2004 11:03:00
The first object is in the String pool and is never garbage collected, a least for purposes of the
SCJP 1.4, SCWCD in process
Joined: Sep 20, 2004
Nov 24, 2004 12:22:00
if you take, how many objects will be eligible for GC just after this method returns?
public void compute(Object p)
String str = "abc";
"abc" is a string literal which goes to the string pool and is not GCed.
I agree. Here's the link:
subject: String object : Garbage Collection
what is Stringpool and heap
Shifting and Garbage Collection
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015