title: Writing an iterator that wraps starts towards the end and wraps around to print all elements in order
body: <p>I need to write an Iterator for a wrap around array in which the front of the list starts towards the end. So the Iterator needs to start at the "front" variable, iterate until the end of the list, and then start at the beginning of the list and iterate until it hits "rear".</p>
  
  <p>the last element in the array "rear" is not being printed and when the array is full it does not print any of the elements. </p>
  
  <pre><code>public Iterator&lt;E&gt; iterator(){      
      return new IteratorAssist();
  }
  
  class IteratorAssist implements Iterator&lt;E&gt; {
  
      public IteratorAssist() {
          index = front;
      }
      @Override
      public boolean hasNext() {
  
          if(index != data.length)
              return index != rear + 1 ;
          else if(index == data.length)
              index = 0;
          return index != rear + 1;
      }
      @Override
      public E next() {
          if(!hasNext())
              throw new NoSuchElementException();
          return data[index++];
      }
  }
  </code></pre>