title: How to use Enumeration?
body: <p>I was reading Enumerations in Java, and every example I have come across uses the Vector, and then uses <code>Vector.elements()</code> to get the Enumeration to iterate using <code>Enumeration.nextElement()</code>.</p>
  
  <p>My question is how to use the Enumeration interface with my classes, for example if I create a simple class that implements Enumeration like so:</p>
  
  <pre><code>public class Tester implements Enumeration{
  
      private int [] arr = new int[5];
      private int iterator = 0;
      private int count = 0;
  
      public boolean insert(int item)
      {
          if (count &lt; 5)
          {
              arr[count-1] = item;
              count++;
              return true;
          }
          else
          {
              return false;
          }
      }
  
      public boolean hasMoreElements() {
          if (iterator &gt;= 4)
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  
      public Object nextElement()
      {
          if (iterator &lt; count)
          {
              iterator++;
              return (Object)arr[iterator -1];
          }
          else
          {
              iterator = 0;
              return nextElement();
          }
      }
  }
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Whats next? I mean how do I use the Enumeration interface with this
  class? What can I do with it (please also explain the purpose of
  Enumeration and implementing it in a class)?</li>
  <li>How to write the Tester.elements() function similar to
  Vector.elements() which is used in the examples over the internet?</li>
  <li>What is its equivalent in C#?</li>
  </ol>