title: toString() method for Queue class
body: <p>Just a simple question, if I created a <code>Queue</code> class and initialized this </p>
  
  <pre><code>Queue queue = new Queue(5)
  </code></pre>
  
  <p>In the main method, and then enqueued and dequeued accordingly,</p>
  
  <p>with the following instance variables, and <code>toString()</code> method:</p>
  
  <pre><code> private int maxSize;
   private Planes[] queArray; 
   private int front;
   private int rear;
   private int nItems;
  
   public String toString()
   {
     String result = "[";
     for(int i = 0; i &lt;= rear; i++)
     {
       result += " " + queArray[i];
  
       if(i &lt;= rear - 1)
         result += ",";
     }
     result += " ]";
     return result;
   }//toString`
  </code></pre>
  
  <p>What variable do I stop at in the <code>for</code> loop: </p>
  
  <p><code>for(int i = 0; i &lt;= rear; i++)</code>, </p>
  
  <p>Right now I have it at <code>rear</code>, which doesn't seem to work how I want it to, and I know it's not <code>nItems</code>, or <code>maxSize</code> because that will print the entire <code>queue</code>, including the empty slots, and I just want the updated <code>queue</code>. 
  I know for a <code>Stack</code>, you only print up to the <code>top</code> variable, but I'm more confused for the <code>Queue</code> class.</p>
  
  <p>These are my <code>enqueue</code> and <code>dequeue</code> methods:</p>
  
  <pre><code> public void enqueue(Plane name)
   {
     if(rear == maxSize-1)
     {
       rear = -1;
     }
     rear++;
     queArray[rear] = name;
     nItems++;
   }
  
   public Plane dequeue()
   {
     Plane temp = queArray[front];
     front++;
     if(front == maxSize)
     {
       front = 0;
     }
     nItems--;
     return temp;
   }
  </code></pre>