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 Where do Variables live? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where do Variables live?" Watch "Where do Variables live?" New topic
Author

Where do Variables live?

Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Greetings Java Ranchers,

Excuse my ignorance, Could someone please tell me where do Primitive variables live? I understand java puts the binary representation of the value inside a variable, but I want to know where exactly does this variable reside?

Is it on the heap? like the objects do?

and....reference variables live in the same place as primitives, right?

Thank you very much in advance. Hopefully you won't laugh at my question.
-Jose
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Local variables live on the stack. There is a separate stack for each thread.

If a primitive is a local variable, it will be on the stack.

If a primitive is a field of an object, it will be in the heap.

-- Kaydell
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Thanks,
I didn't remember those rules, you have refreshed my mind !

Thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where do Variables live?