VOOZH about

URL: https://www.geeksforgeeks.org/java/how-to-iterate-over-a-queue-in-java/

⇱ How to Iterate over a Queue in Java? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Iterate over a Queue in Java?

Last Updated : 23 Jul, 2025

Queue is a concept of Linear Data Structure that follows the concept of FIFO(First In First Out). Queues are majorly used to maintain the order of the elements to which they are added. In this article, we will learn to perform Queue Iteration in Java.

Queue Iteration Program in Java

Syntax with Examples

Iterator<String> it = queue.iterator();
while (it.hasNext()) {
// print elements
}

Below is the program for Queue Iteration in Java:


Output
Shivansh
Sohan
Mohan
Shivam
Radha
Rakesh


Comment