Can we overload Java main method?



Yes, we can overload the main method of Java. But JVM will only call the default main method only. See the example below.

Example

Live Demo

public class Tester {
   public static void main(String args[]) {
     System.out.println("Default Main");  
   }
 
   public static void main(String args) {
      System.out.println("Overloaded Main");
   }
}

Output

Default Main

Advertisements