import java.util.*; public class HW7A { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub LinkedList l1, l2; l1 = new LinkedList(); l2 = new LinkedList(); for (int i = 0; i < 100; i = i + 5) { l1.add(new Integer(i)); } for (int i = 0; i < 100; i = i + 7) { l2.add(new Integer(i)); } System.out.println(union(l1,l2)); System.out.println(intersection(l1,l2)); Iterator itr = l2.iterator(); addToList(l1, itr); System.out.println(l1); } public static List union(List lst1, List lst2) { /* Should return a List (ArrayList or LinledList) consisting of all things that are * in either lst1 or * lst2. The contains method should be used to determine if a list contains a certain * object. Assuming lst1 and lst2 have no duplicates, the output should also have no * duplicates. Don't assume that the input lists are ordered in increasing or * decreasing order of any kind. */ } public static List intersection(List lst1, List lst2) { /* Should return a List consisting of all things that are in both lst1 and * lst2. The contains method should be used to determine if a list contains a certain * object. Assuming lst1 and lst2 have no duplicates, the output should also have no * duplicates. Don't assume that the input lists are ordered in increasing or * decreasing order of any kind. */ } public static void addToList(List lst, Iterator itr){ /* itr is an iterator on a collection , whereas lst is a possibly different * LinkedList. The method should add all things in the collection corresponding to itr * to the List lst, but it should not add an object that is already in lst * (as determiend by the contains method). Can assume that lst and the colelction have * no duplicates by themselves. */ } }