I\'m just beginning to write programs in Java. What does the following Java code mean?
public static void main(String[] args)
What
I think it's pretty well covered by the answers above that String args[]
is simply an array of string arguments you can pass to your application when you run it. For completion, I might add that it's also valid to define the method parameter passed to the main
method as a variable argument (varargs) of type String:
public static void main (String... args)
In other words, the main
method must accept either a String array (String args[]
) or varargs (String... args
) as a method argument. And there is no magic with the name args
either. You might as well write arguments
or even freddiefujiwara
as shown in below e.gs.:
public static void main (String[] arguments)
public static void main (String[] freddiefujiwara)