Can we overload the main method in Java?

Yes, we can overload the main method in Java, but When we execute the class JVM starts execution with public static void main(String[] args) method

 

public class Sample{
   public static void main(){
      System.out.println("Method of overloaded main ");
   }
   public static void main(String args[]){
      Sample obj = new Sample();
      obj.main();
   }
}

 

Output:

Method of overloaded main

 


Subscribe For Daily Updates

Flutter Questions
Android Questions