Not every JAVA Class, but every JAVA program requires a Main method. The Main method can be seen as the startup method, that is executed when you start the program. The String args[] parameters contains the the parameters that you pass to the program on the JAVA commandline.
Example: java yourprogram parm1 parm2
passes parm1 and parm2 as String args[0] and args[1] to your Main method in program yourprogram.
I'm not sure if the compiler will allow you to compile without it anymore (been a while). But look at it this way, if you did write your code with the array in your main statement and then attempted to run your program, but accidentally (or someone else intentionally) included parameters after the java yourprogram, what would happen? since the only available function is main() but it is not accepting I would assume (and will shortly try this out myself) that you are gping to get at the very least a method not found error.
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.