aspose file tools*
The moose likes Beginning Java and the fly likes doubt regarding primitives in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubt regarding primitives in Java" Watch "doubt regarding primitives in Java" New topic
Author

doubt regarding primitives in Java

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Hi

Are primitives also Objects in Java? If not , then what are they? Where are they stored in the memory? Stack?


~ Mansukh
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

They are not Objects. They are primitives.


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
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7795
    
  21

Mansukhdeep Thind wrote:Are primitives also Objects in Java? If not , then what are they? Where are they stored in the memory? Stack?

Mansukhdeep,

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.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt regarding primitives in Java