This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Doubt in stack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Doubt in stack" Watch "Doubt in stack" New topic
Author

Doubt in stack

Dhivya rajagopal
Ranch Hand

Joined: Dec 15, 2010
Posts: 42

hi, i read that object references will store in stack memory. The Java system must know, while it is creating the program, the exact lifetime of all the items that are stored on the stack. i can't understand this. can you please explain it. what are the items will store in the stack?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38467
    
  23
Not a “beginning” question, so I shall move it.

Who told you objects live on the stack? That sounds mistaken. There are a few short-lived objects which are created on the stack (in Java6+ only), but other objects live on the heap. There are copies of their references on the stack as local variables, but that probably doesn’t answer your question.
As for finding the age of objects, it is worth googling for Java garbage collection.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in stack