import java.util.*;
import java.util.function.*;

public class PrintCollection {
	public static void main(String [] args) {
		ArrayList<Integer> a = new ArrayList<Integer>(Arrays.asList(new Integer [] {1, 2, 3, 4, 5, 6}));
		printCollection(a, new ElementPrinter<Integer>());
	}

	static <T> void printCollection(Collection<T> c, Consumer<T> action) {
		for (T e : c)
			action.accept(e);
	}

	static class ElementPrinter<T> implements Consumer<T> {
		public void accept(T t) {System.out.println(t);}
	}
}
