Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/util/Enumeration.java
38829 views
/*1* Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.util;2627/**28* An object that implements the Enumeration interface generates a29* series of elements, one at a time. Successive calls to the30* <code>nextElement</code> method return successive elements of the31* series.32* <p>33* For example, to print all elements of a <tt>Vector<E></tt> <i>v</i>:34* <pre>35* for (Enumeration<E> e = v.elements(); e.hasMoreElements();)36* System.out.println(e.nextElement());</pre>37* <p>38* Methods are provided to enumerate through the elements of a39* vector, the keys of a hashtable, and the values in a hashtable.40* Enumerations are also used to specify the input streams to a41* <code>SequenceInputStream</code>.42* <p>43* NOTE: The functionality of this interface is duplicated by the Iterator44* interface. In addition, Iterator adds an optional remove operation, and45* has shorter method names. New implementations should consider using46* Iterator in preference to Enumeration.47*48* @see java.util.Iterator49* @see java.io.SequenceInputStream50* @see java.util.Enumeration#nextElement()51* @see java.util.Hashtable52* @see java.util.Hashtable#elements()53* @see java.util.Hashtable#keys()54* @see java.util.Vector55* @see java.util.Vector#elements()56*57* @author Lee Boynton58* @since JDK1.059*/60public interface Enumeration<E> {61/**62* Tests if this enumeration contains more elements.63*64* @return <code>true</code> if and only if this enumeration object65* contains at least one more element to provide;66* <code>false</code> otherwise.67*/68boolean hasMoreElements();6970/**71* Returns the next element of this enumeration if this enumeration72* object has at least one more element to provide.73*74* @return the next element of this enumeration.75* @exception NoSuchElementException if no more elements exist.76*/77E nextElement();78}798081