• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Order of initialization

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i wanted to know in what order does a class initialize meaning if u have a'
1)set of class level variables
2) static block initializer
3)instancs block initializer
which would initialize first?

thanks in advance
sunil.s
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sunilkumar ssuparasmul:
i wanted to know in what order does a class initialize meaning if u have a'
1)set of class level variables
2) static block initializer
3)instancs block initializer
static blocks and static variables, if any ,would get initialised first. These are initialised when the class gets loaded. as these are per class variables
The next comes initalisation of other class variables and instance blocks. And these occur when ever an object of the class
created and these get initialised in the order they are declared in the Class definition.
HTH
Sasi
which would initialize first?

thanks in advance
sunil.s


 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
i think static initialisers ans static blocks are initialised first before instance variables and even main method.Correct me if i am wrong
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic