How to create a method that accept varargs in Java?
Varargs (variable arguments) is a new feature in Java 1.5 which allows us to pass multiple values in a single variable name when calling a method. Of course it can be done easily using array but the varargs add another power to the language.
The varargs can be created by using three periods (...) after the parameter type. If a method accept others parameter than the varargs, the varargs parameter should be the last parameter to the method. And please be aware that overloading a varargs method can make harder to figure out which method is called in the code.