I was wondering always, why it is always main method is the starting point for the Java program.

Well When i was matured enough to read the Java Specification i learnt why and whether can it be changed ? Okay Lets See !!

Why main method ?

Main method is the starting point for the java program, JVM initialize the class and invokes main method, having below listed specifications (reference 12.1.4). 

  • Should be named as main 
  • Should be public 
  • Should be static 
  • Should accept String array as argument. 
  • Return type is void 

As based on the above specification, we can conclude that we cannot rename the main method. 

Some Additional Info.!

public static void main(String[] args)  // this is valid

public static void main(String… args)  //String…  this is also valid where it is available from the java 5

public static void main(String args[]) //This is valid but not recommended because the array brackets in the variable)

Please disable your adblocker or whitelist this site! We Provide Free content and in return, all we ask is to allow serving Ads.

Pin It on Pinterest

Share This
%d bloggers like this: