String
is a string type. String[]
is an array of strings.
String ...
is a syntactic sugar called ellipsis, introduced in java 1.5 and taken from C. It can be used in method definitions and is actually the same as an array with only one difference. If the method is defined as:
public void foo(String[] arg){}
you must pass an array:
foo(new String[] {"a", "b"});
If the method is defined as:
public void foo(String arg){}
You can call it
foo(new String[] {"a", "b"});
or
foo("a", "b");
Alexr source share