Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where does static variables live?

 
William Yan
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Where do static variables (yes, they must be instance variables) live? As the book says, instance variables live IN the object on the heap, static variables are shared with all the objects of the very class, so where are they?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the heap, in the instance of the Class object created to represent the class when it gets loaded? Here I am assuming you are writing about the class variables. The objects referred to by those class variables (if they are reference variables) are just regular objects on the heap.
[ October 11, 2006: Message edited by: Barry Gaunt ]
 
William Yan
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Barry.
And the Class object of a class must be a singleton, right?
 
Pavan Sambare
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one Class object for each class in the jvm. This Class Object is created by the ClassLoader when it is loading the class.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic