Easy learning with example program codes

can we overload main() method in java?

Yes, we can overload main() method. A Java class can have any number of main() methods. But it should have one main() method with signature as “public static void main(String[] args)” to run. If not class will compile but not run.


 * This class is used for main method overloading.
 * @author CodesJava
public class MainMethodOverloding {
      //overloaded main method with one parm
      public static void main(int num1){
      //overloaded main method with two parm
      public static void main(int num1, int num2){
            System.out.println(num1 + num2);
      public static void main(String args[]){
            //method call
            main(10, 20);



Java interview questions on main method

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki