Can I have multiple main() methods in the same class?

Can I have multiple main() methods in the same class?

Hi,

Can I have multiple main() methods in the same class?

View Answers

April 9, 2013 at 3:24 PM

Hi,

No, We cann't use multiple main() method within the same class. If we do this then the program fails to compile. The Compiler gives error that the main method is already defined in the class..

For more details related to use of multiple main() method in same class


April 10, 2013 at 2:52 PM

yes, it is possible with defining the main method with different parameters.









Related Tutorials/Questions & Answers:

Ads