Java Program to Create a Queue Using Linkedlist

You are currently viewing Java Program to Create a Queue Using Linkedlist

Java program to create a Queue using LinkedList

// Java program to create a Queue 
// using LinkedList

import java.util.LinkedList;
import java.util.Queue;

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

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

    System.out.println("Queue elements: \n" + queue);
  }
}

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