Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static initializers v static blocks.

Neil Mc
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is executed first when a class is loaded into the JVM... a static initializer statement or a static block..... or are they simply executed in the order in which they occur ?
Does the same apply to instance initializers and blocks ?
Also if we have a static variable with an initializer statement say...
static int i = 5;
Will i be initialized directly to 5 or will it first be initialized to its default value (0) and then have its initializer statement executed - giving it the value 5.
Thanks in advance - Neil.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic