aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confusion in heap and stack - PLEASE HELP 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 "confusion in heap and stack - PLEASE HELP" Watch "confusion in heap and stack - PLEASE HELP" New topic
Author

confusion in heap and stack - PLEASE HELP

gaurav pal
Greenhorn

Joined: Feb 23, 2009
Posts: 3
i read in K&B that all objects are created/stored on heap and local variables(including object references) are created/stored in stack. But I want to know that where are the instance variables, which are primitives are stored... ?
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
all the instance variables will be saved in the heap.


SCJP 1.5
"A candle looses nothing by lighting another candle"
itechmentors.com
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
Welcome to JAVARANCH Family
gaurav pal
Greenhorn

Joined: Feb 23, 2009
Posts: 3
can you tell me that how a heap does memory management i.e. how does it store new variables and deletes old variables... ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14144
    
  18

Welcome to JavaRanch.

The Sun Certification Results forum, where you posted this, is not for asking questions like yours, but for posting your result when you passed a Sun certification exam. I will move your post to a more appropriate forum.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

gaurav pal wrote:can you tell me that how a heap does memory management i.e. how does it store new variables and deletes old variables... ?


Memory for Objects is allocated(on heap) when you create one using the "new" keyword. Freeing the memory is taken of by the garbage collector(which runs at its own discretion). Read up on garbage collection.

In Java, you dont have to worry about explicit memory allocation and de-allocation like you'd have to in C[malloc and free].
That said, you still have to take care that your code has no memory leaks and that it uses the memory efficiently.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion in heap and stack - PLEASE HELP