title: implementing queue with arrays
body: <p>im very confused as to why my queue is not working, i believe that there is a problem in the enqueue and dequeue methods. but im not sure, i am supposed to Implement the class with the initial array size set to 8. The array size will be doubled once the number of the elements exceeds the size. After an element is removed from the beginning of the array, you need to shift all elements in the array one position the left. Write a test program that adds 20 numbers from 1 to 20 into the queue and removes these numbers and displays them.   here is my code</p>
  
  <pre><code>    public class Queue {
      private int[] elements;
      private int size;
      private int first;
      private int last;
      public static final int DEFAULT_CAPACITY = 8;
  
      public Queue(){
          this (DEFAULT_CAPACITY);
      }
      public Queue (int capacity){
          elements = new int[capacity];
          first = 0;
          last = 0;
          size = 8;
      }
      public void Enqueue(int v){ //fills queue and lengthens if necessary
          if (last&gt;=size){
              int[] temp = new int[elements.length*2];
          System.arraycopy(elements, 0, temp, 0, elements.length);
              elements = temp;
          }
          elements[last]=v;
          last++;
  
      }
      public int Dequeue(){    
           int output = elements[first];
           System.out.print(output + " ");
          while(last != 0){
              for(int i = 0; i&lt;last;i++){
                  elements[i]= elements[i-1];
              }
              last--;
          }
          return output ;
      }
      public boolean empty(){ // tests for empty queue
  
  
          return last==first;
  
      }
      public int getSize(){
          size=last;
          return size;
      }
      }
  </code></pre>
  
  <p>and here is the tester class.</p>
  
  <pre><code>    public class QueueTester {
      public static void main(String[] args){
          Queue q = new Queue();
          q.Enqueue(1);
          q.Enqueue(2);
          q.Enqueue(3);
          q.Enqueue(4);
          q.Enqueue(5);
          q.Enqueue(6);
          q.Enqueue(7);
          q.Enqueue(8);
          q.Enqueue(9);
          q.Enqueue(10);
          q.Enqueue(11);
          q.Enqueue(12);
          q.Enqueue(13);
          q.Enqueue(14);
          q.Enqueue(15);
          q.Enqueue(16);
          q.Enqueue(17);
          q.Enqueue(18);
          q.Enqueue(19);
          q.Enqueue(20);
          while (q.empty()){
              q.Dequeue();
  </code></pre>