I have been exposing myself to more things lately. I see a lot of methods that take parameters with ... in them. I know it's not morse code because I'm pretty sure that was depreciated with Java 1.3 (LOL!!)
What does it mean, how is it used, what is it called? (so maybe I can look up more stuff on google one day.... it's not easy to search for '...')
When you do things right, people won't be sure you've done anything at all.
Varargs in Java works like a kind of syntactic sugar for arrays. Note that you can change any method that takes an array and change it to a method that takes varargs; to the JVM, the methods will look the same. So you can even change your main() method to this:
Janeice DelVecchio wrote:Can you override, like this?
If so, which one gets picked at runtime?
Do you mean overload? Then, no. Since var-args with string is just an string array, the compiler will complain that the two methods have the same signature.
Janeice: the third version can be coexist with either of the other two, as an overload. But the first two cannot exist in the same class. If you call methodOne("A") (with exactly one argument) then the one-argument version (version 3) will be called in preference to either other version. For any other number of arguments, the one-argument version cannot be called.