VarArgs1.java
Select all
/* VarArgs1.java CIS 260 2/16/2005 David Klick Demonstrates the use of the new Java 1.5 variable argument feature, syntax, and usage. */ import java.util.*; public class VarArgs1 { public static void main(String[] args) { System.out.println("Max of 3, 5, 18, 2, -9, 14 is " + max(3, 5, 18, 2, -9, 14)); } static int max(int first, int... rest) { int max = first; for (int i : rest) if (max