... μπορούμε να ορίσουμε
ότι μια μέθοδος λαμβάνει ως όρισμα μεταβλητό αριθμό παραμέτρων,
ίδιου τύπου, ως πίνακα.
public class Varargs {
static int sum(int... numbers) {
int total = 0;
for (int n : numbers)
total += n;
return total;
}
public static void main(String[] args) {
System.out.println(sum()); // 0
System.out.println(sum(5)); // 5
System.out.println(sum(1, 2, 3)); // 6
}