import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import javax.swing.JOptionPane; /** * * @author Bill Kraynek * * COP3337 Example */ public class TestMyLinkedCollection { /** * @param args the command line arguments */ public static void main(String[] args) { Collection c = new MyLinkedCollection(); String out = ""; c.add(37); c.add(371); c.add(7); c.add(37); c.add(73); c.add(100); c.add(10); c.add(4); out += "c is " + c + "\n"; Integer[] numbers = c.toArray(new Integer[0]); out += "numbers is " + Arrays.toString(numbers) +"\n"; out += "c.remove(37) " + c.remove(37)+ " c.remove(101) " + c.remove(101) + "\n"; out += "Now c is " + c + "\n"; Collection myC = new MyLinkedCollection(c); out += "myC is " + myC + "\n"; out += "c.contains(4) " + c.contains(4) + "\n"; out += "Test iterator\n c is "; Iterator itr = c.iterator(); while (itr.hasNext()) { out += itr.next() + " "; itr.remove(); }// end while out += "\n"; c.add(137); out += "Now c is " + c + "\n"; JOptionPane.showMessageDialog(null, out); } }