Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Can I have multiple main() methods in the same class?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
Can I have multiple main() methods in the same class?
2 Answer(s)      a year and 5 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:
 

 

 

DMCA.com