Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When will a variable use memory from stack and when will use memory from heap?

 
Mr Chan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When will a variable use memory from stack and use memory from heap?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is not based on I/O or streams, would probably be better answered in the beginners forum.
 
Jack J. Jackson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Local variables are allocated from stack whereas instance and class variables are allocated as part of object instantiation and consume heap memory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic