1. History. This is a convention since the days of C, maybe even earlier.
Java took most of its syntax from C.
2. When we run a java program to command prompt, we can pass some input to our Java program. Those inputs are stored in this String args array.
Example : if you run your program as,
java MyProgram first second
then args will contain
["first", "second"]
i.e,
arg[0] = "first" arg[1] = "second"
3. Java tend to make it simpler by using simplest of all data-types "String" . Also, all the other datatypes can be easily converted from String.
4. JVM takes care of passing any command line arguments as an array of strings to the main method. If there are no arguments given, an empty array is passed - but it's still there.
Comments
Post a Comment