android - which one is called first static block or oncreate method? -
i want know executed first static block or oncreate method
public class mainactivity extends activity { static{ // dosomething } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); }
a class loaded this
- first, thing static, in order defined.
- then, non static.
- then, contructor
- then, instance methods can called.
so, answer question, static block, oncreate method.
public class example { public static int first = 1; static { // second } public int third = 3; { // forth } public examle(){ // fifth } public void sixth(){ } }
http://javarevisited.blogspot.com/2012/07/when-class-loading-initialization-java-example.html
Comments
Post a Comment