Java main method -


in overloaded main method why main method signature string[] args considered entry point.

e.g.

public class test {     public static void main(string[] args) {         system.out.println("why being printed");     }      public static void main(string arg1) {         system.out.println("why not being printed");     }      public static void main(string arg1, string arg2) {         system.out.println("why not being printed");      } } 

the main method should have 1 argument, of type string[] single string , 2 string forms not valid main methods, , such not options, accepted forms are:

  • public static void main (string[])
  • public static void main (string...)

the second option syntactic sugar first option.

this set in java language specifications:

12.1. java virtual machine startup

the java virtual machine starts execution invoking method main of specified class, passing single argument, array of strings...

link


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -