There must be some expceptoins when it comes to main methods correct? Like there are certain circumstances where main methods aren't nessasary or needed. I would be very appriciateive if someone could lay them out for me.
Printable View
There must be some expceptoins when it comes to main methods correct? Like there are certain circumstances where main methods aren't nessasary or needed. I would be very appriciateive if someone could lay them out for me.
your question is a little vague. And the answer would be enormous. What exactly are you trying to accomplish?
Okay sorry haha..
Revamped question:
Can you have a class without a main method (that will compile, and work)?
Sure, you only need one class with a main method. The main method is the so called program entry point, that is where the program starts.
But you can have several main methods (each in a different class) if you wish. Then the program will have many entry points and you must select which one you want when you start the program.
You need to have the standard main method in any class you try to start by using the java command:
java ThisClassMustHaveMainMethod
public static void main(String args[]) method is only needed to run the program , there is no need for compiling a class. in java an empty class is also valid and compile