Static program

public class staticdemo {


     static
{


     System.out.println("static method");//Static Block will be executed First

}

               public void m2()
         {
       System.out.println("non static");//Non Static method will be executed Second
         }

public  static void main(String[] args)
{
staticdemo s1=new staticdemo();
s1.m2();

}
}

Output:

static method

non static


No comments:

Post a Comment