Ads Sponsored By Google :)

Wednesday, 30 January 2013

how can we call main method explicitly or not with example


can we call main method explicitly or not how can we call main method in java can we call main method explicitly or not with example

  Can we call main method explicitly or not ?
   
      Yes, it is possible we can call main method from static block.

  For Example :
        
           public class Demo2
        {
              static                
            {
              String s[]={};
             main(s);
             main(s);
           }
           public static void main(String args[])
         {
           System.out.println(“ THIS IS MAIN METHOD”);
          }
        
}

  Output:
   THIS IS MAIN METHOD
   THIS IS MAIN METHOD

No comments:

Post a Comment

LinkWithin