1. /*
  2. * @(#)Enumeration.java 1.18 00/02/02
  3. *
  4. * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.util;
  11. /**
  12. * An object that implements the Enumeration interface generates a
  13. * series of elements, one at a time. Successive calls to the
  14. * <code>nextElement</code> method return successive elements of the
  15. * series.
  16. * <p>
  17. * For example, to print all elements of a vector <i>v</i>:
  18. * <blockquote><pre>
  19. * for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
  20. * System.out.println(e.nextElement());<br>
  21. * }
  22. * </pre></blockquote>
  23. * <p>
  24. * Methods are provided to enumerate through the elements of a
  25. * vector, the keys of a hashtable, and the values in a hashtable.
  26. * Enumerations are also used to specify the input streams to a
  27. * <code>SequenceInputStream</code>.
  28. * <p>
  29. * NOTE: The functionality of this interface is duplicated by the Iterator
  30. * interface. In addition, Iterator adds an optional remove operation, and
  31. * has shorter method names. New implementations should consider using
  32. * Iterator in preference to Enumeration.
  33. *
  34. * @see java.util.Iterator
  35. * @see java.io.SequenceInputStream
  36. * @see java.util.Enumeration#nextElement()
  37. * @see java.util.Hashtable
  38. * @see java.util.Hashtable#elements()
  39. * @see java.util.Hashtable#keys()
  40. * @see java.util.Vector
  41. * @see java.util.Vector#elements()
  42. *
  43. * @author Lee Boynton
  44. * @version 1.18, 02/02/00
  45. * @since JDK1.0
  46. */
  47. public interface Enumeration {
  48. /**
  49. * Tests if this enumeration contains more elements.
  50. *
  51. * @return <code>true</code> if and only if this enumeration object
  52. * contains at least one more element to provide;
  53. * <code>false</code> otherwise.
  54. */
  55. boolean hasMoreElements();
  56. /**
  57. * Returns the next element of this enumeration if this enumeration
  58. * object has at least one more element to provide.
  59. *
  60. * @return the next element of this enumeration.
  61. * @exception NoSuchElementException if no more elements exist.
  62. */
  63. Object nextElement();
  64. }