Date: 04/30/06 (Java Web) Keywords: no keywords Varargs allows variable number of arguments in methods and constructors. Let's start with a simple example. public static void main(String … args) { for(String arg:args) { System.out.println(arg); } } Varargs can be thought of as an array with simplifications. A simple use case is: int sum(int… data) Key Points Method with varargs is called only when no other method signature matches the invocation. Only [...]
|