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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -