+ 1
What does *String[] args* mean after main method?
2 Réponses
+ 1
Those are for command-line arguments in Java.
In other words, if you run your java program 'MyProgram' with additional values 'one' and 'two'. As follows,
java MyProgram one two
Then args contains:
[ "one", "two" ]
public static void main(String [] args) {
String one = args[0]; //contains "one"
String two = args[1]; //contains "two"
}
The reason for this is to configure your application to run a particular way or provide it with some piece of information it needs.
0
it is used to take arguments from the command prompt or take the values in runtime