And I believe the answer to where are they stored depends on how they are used. If an object has a primitive member variable, then I believe that the primitive will be stored in the heap with the rest of the Object.
For a method variable, they would be on the stack.
But does it really matter where they are stored? What do you gain by knowing?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mansukhdeep Thind wrote:Are primitives also Objects in Java? If not , then what are they? Where are they stored in the memory? Stack?
This forum is meant to be a source of help; not your own personal reference library. The answers to all those questions can be found in the JLS, the tutorials, or (if you need it) the JVM spec; and I'd suggest that you get used to Searching First before you ask questions, otherwise people are likely to stop helping you.
My answer: No, primitives are not objects. The rest is either irrelevant, or a waste of your valuable time, because it's not something you need to know at the moment.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here