1. /*
  2. * @(#)Enumeration.java 1.20 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.util;
  8. /**
  9. * An object that implements the Enumeration interface generates a
  10. * series of elements, one at a time. Successive calls to the
  11. * <code>nextElement</code> method return successive elements of the
  12. * series.
  13. * <p>
  14. * For example, to print all elements of a vector <i>v</i>:
  15. * <blockquote><pre>
  16. * for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
  17. * System.out.println(e.nextElement());<br>
  18. * }
  19. * </pre></blockquote>
  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.20, 01/23/03
  42. * @since JDK1.0
  43. */
  44. public interface Enumeration {
  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. * Returns the next element of this enumeration if this enumeration
  55. * object has at least one more element to provide.
  56. *
  57. * @return the next element of this enumeration.
  58. * @exception NoSuchElementException if no more elements exist.
  59. */
  60. Object nextElement();
  61. }