Robert

59%
Flag icon
In summary, varargs are invaluable when you need to define methods with a variable number of arguments.
Robert
I think it'd be worth spelling out: varargs is designed for when you expect *developers* to have need to provide a variable number of arguments, not simply to accept inputs with a variable number of elements.. In other words * Will different code invocations of this method provide different numbers of arguments?→ Use varargs * Will the calling code collect a variable length input into an array and then pass it into this method? → Don't use varagrs.
Effective Java
Rate this book
Clear rating
Open Preview