fred rosenberger wrote:it's a way to get arguments into the program from the command line. if your class with the main() method is called "foo", you could do this on the command line:
>java foo argument1 argument2 argument3
with as many arguments as you want. The all get stored in that "args" array, which you can then pull apart and used the values in your program.
Campbell Ritchie wrote:Welcome to the Ranch
The main() method is called by the JVM when it starts up; it is the first code you actually run. Your program always starts with the main method, and the Java Language Specification (=JLS) gives you two recommended forms for the method header. You are allowed slight changes; for example public static void main(final String args) will work, but any major changes will cause your program to fail to run. Our FAQ makes some useful suggestions about the use of the main method.
Amol Araragi wrote:, so it basically allows us to use arguments in cmd?
Yes, as did a similar construct in the earlier language C. As Fred ahs told you already, you can use the command‑line arguments or ignore them and it is up to you. I suggest you should be careful about command‑line arguments because your users might not know what they mean. The following is one possible solution:-
Amol Araragi wrote:. . . allows us to use arguments in cmd?