I\'m just beginning to write programs in Java. What does the following Java code mean?
public static void main(String[] args)
What
String [] args
is also how you declare an array of Strings in Java.
In this method signature, the array args
will be filled with values when the method is called (as the other examples here show). Since you're learning though, it's worth understanding that this args
array is just like if you created one yourself in a method, as in this:
public void foo() {
String [] args = new String[2];
args[0] = "hello";
args[1] = "every";
System.out.println("Output: " + args[0] + args[1]);
// etc... the usage of 'args' here and in the main method is identical
}