Possible Duplicate:
java: how can i create a function that supports any number of parameters?
I don't understand the concept of var-args. Please explain them to me with a simple example.
They just give you an easy way to pass an undefined number of arguments (all of the same type) to a function. All it's really doing is creating an array out of the arguments you pass in, but it makes it so you don't need to write all the code to create an array and add elements to it. Instead, you just pass the arguments as "extra" arguments to the method.
精彩评论