24 */ 25 26 package java.util; 27 28 /** 29 * An iterator over a collection. {@code Iterator} takes the place of 30 * {@link Enumeration} in the Java Collections Framework. Iterators 31 * differ from enumerations in two ways: 32 * 33 * <ul> 34 * <li> Iterators allow the caller to remove elements from the 35 * underlying collection during the iteration with well-defined 36 * semantics. 37 * <li> Method names have been improved. 38 * </ul> 39 * 40 * <p>This interface is a member of the 41 * <a href="{@docRoot}/../technotes/guides/collections/index.html"> 42 * Java Collections Framework</a>. 43 * 44 * @author Josh Bloch 45 * @see Collection 46 * @see ListIterator 47 * @see Iterable 48 * @since 1.2 49 */ 50 public interface Iterator<E> { 51 /** 52 * Returns {@code true} if the iteration has more elements. 53 * (In other words, returns {@code true} if {@link #next} would 54 * return an element rather than throwing an exception.) 55 * 56 * @return {@code true} if the iteration has more elements 57 */ 58 boolean hasNext(); 59 60 /** 61 * Returns the next element in the iteration. 62 * 63 * @return the next element in the iteration | 24 */ 25 26 package java.util; 27 28 /** 29 * An iterator over a collection. {@code Iterator} takes the place of 30 * {@link Enumeration} in the Java Collections Framework. Iterators 31 * differ from enumerations in two ways: 32 * 33 * <ul> 34 * <li> Iterators allow the caller to remove elements from the 35 * underlying collection during the iteration with well-defined 36 * semantics. 37 * <li> Method names have been improved. 38 * </ul> 39 * 40 * <p>This interface is a member of the 41 * <a href="{@docRoot}/../technotes/guides/collections/index.html"> 42 * Java Collections Framework</a>. 43 * 44 * @param <E> the type of elements returned by this iterator 45 * 46 * @author Josh Bloch 47 * @see Collection 48 * @see ListIterator 49 * @see Iterable 50 * @since 1.2 51 */ 52 public interface Iterator<E> { 53 /** 54 * Returns {@code true} if the iteration has more elements. 55 * (In other words, returns {@code true} if {@link #next} would 56 * return an element rather than throwing an exception.) 57 * 58 * @return {@code true} if the iteration has more elements 59 */ 60 boolean hasNext(); 61 62 /** 63 * Returns the next element in the iteration. 64 * 65 * @return the next element in the iteration |