CAN WE OVERLOAD THE MAIN() METHOD IN JAVA ?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 942  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    Can we overload the main() method in java ?

     Yes, we can overload the main method in java ,but we need to provide different input parameter.But JVM wil start executing the method having String[] args as parameter

    For Example,

      public class OverLoadMain {
     
            public static void main(int [] ar) {
                  System.out.println(" Overloaded Main");
              }

            public static void main(String [] args) {
                  System.out.println(" Main Methods");
              }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!