• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static variables - kept on Heap or Stack

 
jim gemlo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Instance variables are kept with their objects on the Heap but what about static instance variables? Where are they kept? Since there is one variable per class regardless of how many objects are created, are they stored outside of the object on the heap or are they put on the stack?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this post with a very erudite answer from Ernest.

The short answer is, it depends. It's not the stack. It may be the heap, but technically it can't be. It's in some memory that the JVM has access to that isn't the heap. That's what I understood. Oh, and it doesn't matter.

Jules
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic