• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static Initialization block  RSS feed

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
When i use static initialization blocks in the super classes,and print the contents in the initialization blocks,i always get them in the order of class hierarchy.But as we know that static blocks run when the class is loaded,does this imply that whenever we create an instance of a sub-class,then first all of its super-classes will load and then in the end the subclass loads?
Please help me with this doubt.
Thanks...
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudhanshu Mishra wrote:whenever we create an instance of a sub-class,then first all of its super-classes will load and then in the end the subclass loads?

Yes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!