how to iterate a queue in java

Solutions on MaxInterview for how to iterate a queue in java by the best coders in the world

showing results for - "how to iterate a queue in java"
Laura
09 Feb 2017
1Queue<Integer> queue = new LinkedList<Integer>();
2        queue.add(1);
3        queue.add(2);
4        queue.add(3);
5 
6        for (Integer item: queue) {
7            System.out.println(item);
8        }