posted 13 years ago
That is right mohan,
You have all the reasons right there, if that is the main method we are talking about, then the parameter list is missing (String args[]) this is to pass some parameters at the time of running the program, also note that you can also have overloaded main methods in your class however the "public static void main(String args[]){} will be the one that will be called when you run your program.
Hope it clears all the things.
You have all the reasons right there, if that is the main method we are talking about, then the parameter list is missing (String args[]) this is to pass some parameters at the time of running the program, also note that you can also have overloaded main methods in your class however the "public static void main(String args[]){} will be the one that will be called when you run your program.
Hope it clears all the things.
Impossible is I M Possible
posted 13 years ago
The presence of the main method means you can start the class from the command line. If you have a system of many classes you need at least one that can be started this way. All the other classes don't really need a main method.
I used to put a main on a lot of classes that didn't really require one and put some tests in there. Call a few methods, check the results. You may still see some main methods just for testing. But nowadays I've switched to doing that kind of thing from JUnit tests instead.
I used to put a main on a lot of classes that didn't really require one and put some tests in there. Call a few methods, check the results. You may still see some main methods just for testing. But nowadays I've switched to doing that kind of thing from JUnit tests instead.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi