Russ Russell wrote:Thanks for the replys. So are both ways considered valid var-args syntax?
No. Varargs is only the (...) syntax. If a method is declared to take a Foo[], then you have to pass a Foo[]. But if it is declared to take Foo..., then you can pass (foo1, foo2, foo3). Inside the method, it's the same either way: a Foo[]. This is what I stated in my first reply. Not sure what part is not clear.
According to the SCJP Study Guide, this one is not considered valid (although it does compile and work):
It's valid in that it is a legal way to declare a method. It is not varargs though.
And by the way, I can call my hellow world program from the command line using java Test "hello", "world". Or with any number of args inputed.
That's a totally different issue than calling a Java method from within Java code. The command shell takes your "H" and "W" command line args, passes them at indices 1 and 2 in the argv parameter of a C function
int main(int argc, char* argv[] ) (index 0 is the program being executed, e.g. java.exe) that is the entry point for the JVM, which in turn passes them appropriately to your main().
You cannot, however, in your Java code, pass "hello", "world" to a method that takes String[] rather than String...