• Post Reply Bookmark Topic Watch Topic
  • New Topic

static initializer block  RSS feed

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a variable declared inside a static initializer block can not be accessed in main() as shown in code, then whats the use of such a variable ? Where can I use this variable ? Whats the point in using static initializer block ?
 
Neelesh Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear,
Static Initialization Blocks as the name says Initialize the variables. They are run just once even before the constructor of the class is run. So you can use these blocks to initialize variables.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!