Lecture 4
6
// Fig 6.9, 6.10, pg 192, 194.
package weiss.util;
public interface Collection extends java.io.Serializable
{
   int size( );
   boolean isEmpty( );
   boolean contains( Object x );
   boolean add( Object x );
   boolean remove( Object x );
   void clear( );
   Iterator iterator( );
   Object [ ] toArray( );
}
public interface Iterator
{
   boolean hasNext( );
   Object next( );
   void remove( );
}
// Fig 6.11, pg 195
public static void printCollection
(Collection c)
{
    Iterator itr = c.iterator();
    while (itr.hasNext())
        System.out.println(itr.next());
}