diff --git a/java/09_queue/CircularQueue.java b/java/09_queue/CircularQueue.java index 71a988c..e65313f 100644 --- a/java/09_queue/CircularQueue.java +++ b/java/09_queue/CircularQueue.java @@ -37,7 +37,7 @@ public class CircularQueue { public void printAll() { if (0 == n) return; - for (int i = head; i % n != tail; ++i) { + for (int i = head; i % n != tail; i = (i + 1) % n) { System.out.print(items[i] + " "); } System.out.println();