FileDocCategorySizeDatePackage
VarArgsDemo.javaAPI DocExample809Sun Mar 07 10:35:14 GMT 2004None

VarArgsDemo.java

import java.io.PrintStream;
import java.util.Date;

/**
 * VarArgsDemo - show 1.5 variable arguments
 * @author ian
 * @version $Id: VarArgsDemo.java,v 1.1 2004/03/07 16:35:13 ian Exp $
 */
public class VarArgsDemo {

	public static void main(String[] args) {
		process(System.out, "Hello", "Goodbye");
		process(System.out, 42, 1066, 1776);
		process(System.out, "Foo", new Date(), new Object());
	}
	static void process(PrintStream out, Object ... args) {
		line();
		for (int i = 0; i < args.length; i++){
			out.println("Argument " + i + " is " + args[i]);
		}
	}
	static void process(PrintStream out, int ... args) {
		for (int i = 0; i < args.length; i++){
			out.println("Argument " + i + " is " + args[i]);
		}
	}
	private static void line() {
		System.out.println("--------------------------");
	}
}