Java Program to Implement Queue Using ArrayDeque Class

You are currently viewing Java Program to Implement Queue Using ArrayDeque Class

Java program to implement Queue using ArrayDeque class

// Java program to implement Queue 
// using ArrayDeque class

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Queue < Integer > queue = new ArrayDeque < > ();

    queue.add(10);
    queue.add(20);
    queue.add(30);
    queue.add(40);
    queue.add(50);

    Iterator itr = queue.iterator();
    System.out.println("Queue elements: ");
    while (itr.hasNext()) {
      System.out.print(itr.next() + " ");
    }
  }
}

Output

Queue elements: 
10 20 30 40 50

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply