How should I declare main()
method in Java?
Like this:
public static void main(String[] args)
{
System.out.println(\"foo\");
}
>
String...
gets converted to a String[]
. The main difference is that you can call a vararg method in 2 ways:
method(a, b, c);
method(new String[] {a, b, c});
whereas you need to call a method that accepts an array like this:
method(new String[] {a, b, c});
For the main
method it does not make a difference.