The only difference between
foo(String... strings)
and
foo(String[] strings)
for the calling code. Consider this call:
foo("a", "b");
This is valid with the first declaration of foo , and the compiler will emit code to create an array containing references to "a" and "b" at run time. This is not valid with the second declaration of foo , though, since it does not use varargs.
In any case, itโs enough for the caller to explicitly create an array:
for(new String[] { "a", "b" });
Also main (String [] args) in java uses varargs, if not the way we can pass execution parameters to it
When it is written as main(String[] args) , it is not; if you write main(String... args) then this will happen. This has nothing to do with the way the JVM treats it, because initializing the JVM creates an array with command line arguments. This will only matter if you write your own code to explicitly call main .
source share