Can we overload Main method in Java? And what if if did overload it i.e. from which method the main thread will start from? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can we overload Main method in Java? And what if if did overload it i.e. from which method the main thread will start from?

21st Nov 2017, 6:34 PM
Riyashi Chandak
Riyashi Chandak - avatar
3 Answers
+ 2
The main method used by the JVM as the entry point must respect the signature "public static void main" which by the way works the same "static public void main" and it must respect the parameters "Array of String (String [] args)", if you change only the parameters (overloading) then the JVM will see your version of "main" as a common method instead of the entry point for the java application. It's not recommended at all to overload or overwrite the main method.
22nd Nov 2017, 6:51 PM
Roberto Guisarre
Roberto Guisarre - avatar
+ 2
yep
21st Nov 2017, 6:39 PM
Roabs
Roabs - avatar
- 1
yes
21st Nov 2017, 6:44 PM
Faisal Rahman
Faisal Rahman - avatar