wood burning stoves 2.0
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where do Variables live?" Watch "Where do Variables live?" New topic

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.
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
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?
It's not a secret anymore!