Skip to content

TypeScript code snippet – How to implements an empty queue java?

import java.util.*;
 
public class Main {
   public static void main(String[] args) {
    //declare a Queue   
    Queue<String> str_queue = new LinkedList<>();
    //initialize the queue with values
    str_queue.add("one");
    str_queue.add("two");
    str_queue.add("three");
    str_queue.add("four");
    //print the Queue
    System.out.println("The Queue contents:" + str_queue);
    }
}
See also  Python code snippet - How to print a list nicely ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.