Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt regarding primitives in Java

 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Are primitives also Objects in Java? If not , then what are they? Where are they stored in the memory? Stack?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12266
36
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Winston Gutkowski
Bartender
Pie
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic