 <pre><code>while(last != 0){ for(int i = 0; i&lt;last;i++){ elements[i]= elements[i-1]; } last--; } </code></pre> <p>Remove the while loop. If you're trying to make sure it's not dequeueing an empty queue have an if condition check to ensure that the size is > 0.</p> <pre><code> public int Dequeue(){ if (getSize() == 0) { // throw an error or something } int output = elements[first]; System.out.print(output + " "); for(int i = 0; i&lt;last;i++){ elements[i]= elements[i-1]; } last--; return output ; } </code></pre> <p>Additionally you need to print the output in your tester class, and I assume you want to dequeue while the queue is NOT empty:</p> <pre><code> while (!q.empty()){ System.out.println(q.Dequeue()); </code></pre>