Please read our policy on Screen Names. Follow the link on that page, and update your profile. This is not optional.
Second, I'd advice you read some of the topics here, specifically ShowSomeEffort and UseAMeaningfulSubjectLine. You have two threads with the same subject of "Java Classes", which is rather vague. Something like "Size of classes in Java" and "Memory allocation for objects and variables" would have been much better.
To answer your question, both.
reference variables and primitives are on the stack, and get allocated in the stack frame (i think i have my terminology correct). They get automatically deallocated when the frame goes out of scope.
objects are allocated on the heap, as they are created. They get garbage collected when there are no more active references to them, and the JVM feels like doing a GC. [ February 22, 2007: Message edited by: Fred Rosenberger ]
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad: