package variableparameterliste1;

/**
 * Demonstriert die variable Parameterliste die es seit Java5 gibt.
 * 
 * @author Ralf Kunze (rkunze@uos.de), Institut fuer Informatik, Universitaet
 *         Osnabrueck
 * @date 27.04.2007
 */
public class Max {

	public static void main(String[] args) {
		System.out.println(max(-12));
		System.out.println(max(-123,132));
		System.out.println(max(-123,132,234234));
		System.out.println(max(-123,132,-13241234,13241234,322));
		
		
//		System.out.println(max());

	}

	public static int max(int... zahlen) {
		if (zahlen == null || zahlen.length == 0)
			throw new IllegalArgumentException("Mindestens ein Argument erforderlich");
		
		int currentMax = Integer.MIN_VALUE;
		
		for (int i = 0; i<zahlen.length;i++) {
			if(zahlen[i]>currentMax)
				currentMax = zahlen[i];
		}
		return currentMax;
	}
}
