+ 1

How can the main() function be overloaded in Java? Can you please explain me the disadvantages of doing so?

I saw this in one of the questions in Challenges

17th Jun 2018, 7:25 PM
Shashank V Ray
Shashank V Ray - avatar
5 Answers
+ 4
nitish kumar jha Overload main does run because it is called. Try running it. https://code.sololearn.com/cMJttGO8jL75
18th Jun 2018, 1:19 AM
John Wells
John Wells - avatar
+ 6
yes. The String[] version is the only entry point. Any other version has to be called.
18th Jun 2018, 1:30 AM
John Wells
John Wells - avatar
+ 5
This code overloads main. There aren't really any disadvantages. However, I can't think of any reason for doing it either. public class Program { public static void main() { System.out.println("overloaded"); } public static void main(String[] args) { main(); } }
17th Jun 2018, 8:52 PM
John Wells
John Wells - avatar
+ 3
John Wells any benefit of overloading main methods. because the overloaded main method not run....
18th Jun 2018, 1:13 AM
Nitish kumar jha
Nitish kumar jha - avatar
+ 3
John Wells in this situation we can just think the overloaded main method is just as another overloaded method which named as main()...
18th Jun 2018, 1:25 AM
Nitish kumar jha
Nitish kumar jha - avatar