• Post Reply Bookmark Topic Watch Topic
  • New Topic

Do static variables consume memory??

 
Ashish Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do static variables consume memory??
Since static blocks/variables are executed/loaded only at the first time the class is loaded, wiil they be loaded for the entire JVM lifetime or they will be accessed on the fly??
Thanx in advance.
 
Charles Rector
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are loaded on demand (when their containing class is used in some way), and then persist for the duration of the application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!