0

When declaring a primitive type in Java we know that the value is stored in memory location. However, I have understanding that objects on the other hand are not stored in memory (I'm not sure if this is correct or not). If so, where are objects stored?

Sajer
  • 11
  • 3
    Objects are stored on the heap, and Google should answer this general question for you quite quickly. Have you done any research on this problem before coming here? What references do you have that state that objects are "not stored in memory"? – Hovercraft Full Of Eels Apr 28 '15 at 15:59
  • It is worth mentioning that objects, as well as primitives, are stored in memory, but in different sections. As @HovercraftFullOfEels said, Objects are stored on the heap, while primitives are stored on the stack. You can as well store primitives on the heap, i.e. by having primitive as an attribute of an object, but you cannot store object on the stack. – Turing85 Apr 28 '15 at 16:02
  • Note also that regarding, `"If the object name is a reference,..."` -- objects don't have "names". – Hovercraft Full Of Eels Apr 28 '15 at 16:04

0 Answers0