Computer Science 15-110, Fall 2009
Class Notes:  Variable-Length Parameter Lists


class VarArgsDemo {
  public static void main(String[] args) throws Exception {
    System.out.println(max(1,3,5,7,6,4,2));
    System.out.println(max(1,3,5,7,6,4,2,8,3,1,2,5,1,0,2,5));
  }
 
  public static int max(int... a) {
    if (a.length == 0) return 0;
    int max = a[0];
    for (int i=1; i<a.length; i++) max = Math.max(max,a[i]);
    return max;
  }
}

carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem