// Helene Martin, CSE 143 // Demonstrates polymorphism through interfaces: the addAndPrint method will // work for any object type that implements the List interface! public class ListClient { public static void main(String[] args) { List list1 = new ArrayList(); addAndPrint(list1); List list2 = new LinkedList(); addAndPrint(list2); } // Calls several methods on an ArayIntList. // pre: list is not null public static void addAndPrint(List list) { list.add(34); list.add(17); list.add(23); list.add(1, 6); list.set(1, -17); System.out.println(list); list.remove(0); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } } }