Java Coder
Can I have multiple main() methods in the same class?
2 Answer(s)      2 years and 3 months ago
Posted in : Java Beginners

Hi,

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

Advertisement
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: