This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Where do primitive types live? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Where do primitive types live?" Watch "Where do primitive types live?" New topic

Where do primitive types live?

Javier Sanchez Cerrillo
Ranch Hand

Joined: Aug 02, 2006
Posts: 152
It is said that "instance variables" and objects lives in the "Heap" and local variables lives in the "Stack".

But what about primitive types???. Are the same rules are aplied???

class Javier {
int x = 10;
public static void main(String[] args) {
int y = 20;

Where do x and y live?

SCJP 5.0 95%<br /> <br />The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.
john cahil

Joined: Jul 26, 2006
Posts: 12
x will be on Heap & y on stack
I agree. Here's the link:
subject: Where do primitive types live?
Similar Threads
Interesting mock question about arrays and postfix
Usage of "this" keyword
Memory Spaces for primitive types and Objects
Passing objects by reference or value???
java data types initializing