import java.util.Enumeration; class TestAufgabe2 { public static void main(String[] args) { ObjectCollection listCollection = new ObjectList(); ObjectCollection setCollection = new ObjectSet(); for(int i = 0; i < 10; i++) { listCollection.add(new Integer(i % 5)); setCollection.add(new Integer(i % 5)); } System.out.println(); String str = "listCollection = ["; Enumeration e = listCollection.elements(); while(e.hasMoreElements()) { str += e.nextElement().toString(); if (e.hasMoreElements()) str += ", "; } System.out.println(str + "]"); str = "setCollection = ["; e = setCollection.elements(); while(e.hasMoreElements()) { str += e.nextElement().toString(); if (e.hasMoreElements()) str += ", "; } System.out.println(str + "]"); System.out.println(); System.out.println("listCollection.size() = " + listCollection.size()); System.out.println("setCollection.size() = " + setCollection.size()); System.out.println(); Integer int0 = new Integer(0); System.out.println("listCollection.contains(0) = " + listCollection.contains(int0)); System.out.println("setCollection.contains(0) = " + setCollection.contains(int0)); System.out.println(); listCollection.remove(int0); setCollection.remove(int0); System.out.println("listCollection.remove(0)"); System.out.println("setCollection.remove(0)"); System.out.println(); System.out.println("listCollection.contains(0) = " + listCollection.contains(int0)); System.out.println("setCollection.contains(0) = " + setCollection.contains(int0)); System.out.println(); System.out.println("listCollection.size() = " + listCollection.size()); System.out.println("setCollection.size() = " + setCollection.size()); System.out.println(); str = "listCollection = ["; e = listCollection.elements(); while(e.hasMoreElements()) { str += e.nextElement().toString(); if (e.hasMoreElements()) str += ", "; } System.out.println(str + "]"); str = "setCollection = ["; e = setCollection.elements(); while(e.hasMoreElements()) { str += e.nextElement().toString(); if (e.hasMoreElements()) str += ", "; } System.out.println(str + "]"); System.out.println(); } }