• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

static initializers v static blocks.

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic