AndreaNobili AndreaNobili - 3 months ago 23
Java Question

Can I have more than one class containing the main() method in a Java project?

I have a doubt about Java.

In a Java project (handled by Eclipse for example), can I have more classes that contain the main() method and consequently can I chose to execute one class or another class?

Tnx

Andrea

Som Som
Answer Source

Yes, you can have more classes that contain the main() method, but at least one class which contain main() should be public so that JMV will start that class as Main thread

  • as the code written by aUserHimself represent