O'Reilly logo
  • Aadil Hussain thinks this is interesting:

You can define a parameter that can accept variable arguments (varargs) in your methods. Following is an example of the class Employee, which defines a method days-OffWork that accepts variable arguments:

class Employee {
    public int daysOffWork(int... days) {
        int daysOff = 0;
        for (int i = 0; i < days.length; i++)
            daysOff += days[i];
        return daysOff;


Cover of OCA Java SE 8 Programmer I Certification Guide


variable arguments passed