Source Home >> Java Source 1.6.0 >> java.util.Enumeration V 0.09
  • 01/*
  • 02 * @(#)Enumeration.java 1.24 05/11/17
  • 03 *
  • 04 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 05 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 06 */
  • 07
  • 08package java.util;
  • 09
  • 10/**
  • 11 * An object that implements the Enumeration interface generates a
  • 12 * series of elements, one at a time. Successive calls to the
  • 13 * <code>nextElement</code> method return successive elements of the
  • 14 * series.
  • 15 * <p>
  • 16 * For example, to print all elements of a <tt>Vector<E></tt> <i>v</i>:
  • 17 * <pre>
  • 18 * for (Enumeration<E> e = v.elements(); e.hasMoreElements();)
  • 19 * System.out.println(e.nextElement());</pre>
  • 20 * <p>
  • 21 * Methods are provided to enumerate through the elements of a
  • 22 * vector, the keys of a hashtable, and the values in a hashtable.
  • 23 * Enumerations are also used to specify the input streams to a
  • 24 * <code>SequenceInputStream</code>.
  • 25 * <p>
  • 26 * NOTE: The functionality of this interface is duplicated by the Iterator
  • 27 * interface. In addition, Iterator adds an optional remove operation, and
  • 28 * has shorter method names. New implementations should consider using
  • 29 * Iterator in preference to Enumeration.
  • 30 *
  • 31 * @see java.util.Iterator
  • 32 * @see java.io.SequenceInputStream
  • 33 * @see java.util.Enumeration#nextElement()
  • 34 * @see java.util.Hashtable
  • 35 * @see java.util.Hashtable#elements()
  • 36 * @see java.util.Hashtable#keys()
  • 37 * @see java.util.Vector
  • 38 * @see java.util.Vector#elements()
  • 39 *
  • 40 * @author Lee Boynton
  • 41 * @version 1.24, 11/17/05
  • 42 * @since JDK1.0
  • 43 */
  • 44public interface Enumeration<E> {
  • 45 /**
  • 46 * Tests if this enumeration contains more elements.
  • 47 *
  • 48 * @return <code>true</code> if and only if this enumeration object
  • 49 * contains at least one more element to provide;
  • 50 * <code>false</code> otherwise.
  • 51 */
  • 52 boolean hasMoreElements();
  • 53
  • 54 /**
  • 55 * Returns the next element of this enumeration if this enumeration
  • 56 * object has at least one more element to provide.
  • 57 *
  • 58 * @return the next element of this enumeration.
  • 59 * @exception NoSuchElementException if no more elements exist.
  • 60 */
  • 61 E nextElement();
  • 62}

文件:Enumeration.java
包名:java.util
类名:Enumeration
继承:
接口: