File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Where do static variables (class variables) live (scope)? 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 "Where do static variables (class variables) live (scope)?" Watch "Where do static variables (class variables) live (scope)?" New topic
Author

Where do static variables (class variables) live (scope)?

satya mamillapalli
Ranch Hand

Joined: Jun 22, 2005
Posts: 63
Where do they live? stack or heap?

They belong to class not object so does they belong on stack..

Please Advise..
[ August 28, 2005: Message edited by: satya mamillapalli ]
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
object are always be on heap whether its static or not

and static variable will be on stack of Class object which is object of this object ... if i am wrong..pls correct me


Thanks and Regards, Amit Taneja
satya mamillapalli
Ranch Hand

Joined: Jun 22, 2005
Posts: 63
Do they live on stack or heap?
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
local variables live on the stack, class variables,hmmm if a class is instantiated then the object lives in the heap along with it's instance variables & instance methods be they static or non-static.


I'm a Hood Ornament
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where do static variables (class variables) live (scope)?