Can we have two main() methods in a Java Program
Hi…Greetings to Everyone!!!!
I am Jeyakumar.K, Asst. Professor, Dept. of CSE, Kumaraguru College of Technology-Coimbatore. Here I am gonna discuss about calling main() from another main() in a single Java Program.
Don’t be too much surprised guys. Yes we can use two main() methods in a same program but not in the same class. But however, any one main() method would be the starting point of the program execution.
— Save the above program in your local drive as SampleClassOne.java
— Compile the program by using: javac SampleClassOne.java
— Run the program by using: java SampleClassOne
— Then the output will be:
So Guys!!! Just go through the article alone is not enough…. Please try it out and Wish you all good luck!!!! ~ Jeyakumar.K
“Education is learning what you didn’t even know you didn’t know.~Daniel J Boorstin”