home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / util / Iterator.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.0 KB  |  63 lines

  1. /*
  2.  * @(#)Iterator.java    1.6 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.util;
  16.  
  17. /**
  18.  * An iterator over a Collection.  Iterator takes the place of Enumeration in
  19.  * the Java collection framework.  Iterators differ from Enumerations in two
  20.  * ways: <ul> <li> Iterators allow the caller to remove elements from the
  21.  * underlying collection during the iteration with well-defined
  22.  * semantics. <li>Method names have been improved.</ul>
  23.  *
  24.  * @author  Josh Bloch
  25.  * @version 1.6 03/18/98
  26.  * @see Collection
  27.  * @see ListIterator
  28.  * @see Enumeration
  29.  * @since JDK1.2
  30.  */
  31. public interface Iterator {
  32.     /**
  33.      * Returns true if the iteration has more elements.
  34.      *
  35.      * @since JDK1.2
  36.      */
  37.     boolean hasNext();
  38.  
  39.     /**
  40.      * Returns the next element in the interation.
  41.      *
  42.      * @exception NoSuchElementException iteration has no more elements.
  43.      * @since JDK1.2
  44.      */
  45.     Object next();
  46.  
  47.     /**
  48.      * Removes from the underlying Collection the last element returned by the
  49.      * Iterator .  This method can be called only once per call to next  The
  50.      * behavior of an Iterator is unspecified if the underlying Collection is
  51.      * modified while the iteration is in progress in any way other than by
  52.      * calling this method.  Optional operation.
  53.      *
  54.      * @exception UnsupportedOperationException remove is not supported
  55.      *           by this Iterator.
  56.      * @exception IllegalStateException next has not yet been called,
  57.      *          or remove has already been called after the last call
  58.      *          to next.
  59.      * @since JDK1.2
  60.      */
  61.     void remove();
  62. }
  63.