This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
This is the type of question you are probably best investigating by attempting to compile some code to see if it works. Here is an extract from my SCJP5 BOOK
When you see the term VarArgs you can think of it as �Variable number of method arguments�. It is another example of what some people dismissively call �syntactic sugar�, i.e. Something that sweetens the life of the programmer by passing some of the load onto the compiler and relieving the need to create standard �boiler plate� code.
The problem that VarArgs addresses is where you want to pass multiple values as parameters to a method. This problem is addressed in previous versions of Java by allowing you to populate an array and passing it as a parameter to a method. You can see this in action in the way the signature of the default main method accepts a String array, without requiring you to know how many parameters are going to be passed to the method. Passing an array is an acceptable solution to many situations, but for the programmer it represents a step that could be automated by the compiler/runtime and that is what the new VarArgs idea does. The Syntax
The syntax for varargs is that you include three dots after the data type and before the name of the parameter. Those three dots are sometimes called �elipsis�. Note it is three dots and not two (as I mistakenly typed the first time I used this feature).
Note how this code uses the new version of the for loop to iterate through each element of the array that was created and passed to the method. You could treat the parameter in the same way as you would any other array, e.g. You could read its length property to find out the number of elements and walk through it using the original version of the for loop, but why work harder than strictly necessary?