File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Garbage Collection in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Garbage Collection in Java" Watch "Garbage Collection in Java" New topic
Author

Garbage Collection in Java

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

Please Quote Your Sources.


For example, if you had quoted K&B, we would have mentioned that there is something in the Errata related to this very question.

Thanks,
Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

Hoe only 2 objects can be eligible along with those two c3 is also becoming null so can't it be null and along with c3 asso.


And BTW, "c3" was never assigned an object. So, how does assigning it to null make something eligible for GC. Remember, objects are elible for GC -- not references.

Henry
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Thanks Henry!!!

But how Short is eligible.
Does it automatically perform "Boxing" Internally!!!???
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

But how Short is eligible.


In the version that you shown, the object is not eligible for GC. In the correct version (version in the Errata for the book), the object is eligible for GC.


Does it automatically perform "Boxing" Internally!!!???


You are assigning a primative value to a wrapper reference. Of course, autoboxing applies -- it's either that, or a compilation error.

Henry
[ November 30, 2008: Message edited by: Henry Wong ]
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Henry i'm really confuse!!!

If there is an errata in the book. The version is got Java 5.

Then what should be the correct answer?

Thanks.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

Then what should be the correct answer?


As you have the question written? One object is eligible for GC.

As written in the Errata? Two objects are eligible for GC.

Henry
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Thanks a lot Henry!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection in Java
 
Similar Threads
Garbage Collection Doubt
Garbage Collection
K&B ch-3 Ques-2
help scjp5.0 question
question about GC problem in k&b's book for 1.5