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 Object life cycle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Object life cycle" Watch "Object life cycle" New topic
Author

Object life cycle

Sindu Ram
Greenhorn

Joined: Aug 05, 2003
Posts: 6
Hi,
I was recently asked a question about an object life cycle in Java, especially with regard to what happens when we do an
A a = new A();
and what goes to the stack and what to the heap.
Any info would be welcome.
Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Local variables are kept on the stack, while objects are kept on the heap. If this line of code is in a method, then the variable a is on the stack and the A object is on the heap; if it's a line of code at the top level of a class, then a is inside some other object on the heap, and the A is also on the heap.


[Jess in Action][AskingGoodQuestions]
Sindu Ram
Greenhorn

Joined: Aug 05, 2003
Posts: 6
Thank you, Ernest..
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Object life cycle
 
Similar Threads
SimpleTags
Threads
Threads
servlet life cycle
Product Testing life cycle