0

Can we overload the main() method in java? If yes then which will be executed first?

9th Apr 2019, 3:01 AM
Avinash Maurya
Avinash Maurya - avatar
3 Respostas
+ 2
It's just a method, like any other, except that JVM searches for only this method whenever your run your code, and so yes you can overload main as well but remember only public static void main( String[] args) method will be used when you run your program. You can call other overloaded methods inside the main(String[] args) method.
9th Apr 2019, 3:55 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
You can overload the main()method, but only public static void main(String[] args) will be used when your class is launched by the JVM
9th Apr 2019, 6:13 AM
Davide Grimaldi
Davide Grimaldi - avatar
+ 1
You can't overload it cuz it already has a type void and parameter type String array
9th Apr 2019, 3:43 AM
Saksham Jain
Saksham Jain - avatar