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 garbage collection 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 "garbage collection" Watch "garbage collection" New topic

garbage collection

Akhil Gupta

Joined: Apr 22, 2001
Posts: 6
Are primitive datatypes also garbage collected or it is only objects, if no then do we free memory of primitives.
Bryan Timmins
Ranch Hand

Joined: Mar 26, 2001
Posts: 48
No, garbage collection is performed on objects. I think the JVM deals with primitives behind the scenes.

<a href="" target="_blank" rel="nofollow">Bryan Timmins</a> <br />SCJP2
Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
Hello Akhil,
The JVM allocates the memory to primitives when the object of the class having those primitives is created and that memory is de-allocated when that object is garbage collected.
Gurpreet Sachdeva
For any type of information regarding JCP exam(including mock exams) visit at:

Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="" TARGET=_blank rel="nofollow"></A>
I agree. Here's the link:
subject: garbage collection
It's not a secret anymore!