...
| Code Block | ||
|---|---|---|
| ||
class Varargs {
private static void displayManyBooleans(boolean... bool) {
System.out.print("Number of arguments: " + bool.length + ", Contents: ");
for (boolean b : bool)
System.out.print("[" + b + "]");
}
private static void displayTwoBooleans(boolean bool1, boolean bool2) {
System.out.println("Overloaded method invoked");
System.out.println("Contents: [" + bool1 + "], [" + bool2 + "]");
}
public static void main(String[] args) {
displayManyBooleans(true, false);
}
}
|
...