Answers for "java queue remove"

0

java queue remove

import java.util.*;
  
public class QueueDemo {
    public static void main(String[] args)
        throws IllegalStateException
    {
  
        // create object of Queue
        Queue<Integer> queue
            = new LinkedList<Integer>();
  
        // Add numbers to end of Queue
        queue.add(1);
        queue.add(2);
        queue.add(3);
        queue.add(4);
  
        // print queue
        System.out.println("Queue: " + queue);
  
        // print head and deletes the head
        System.out.println("Queue's head: " + queue.remove());
  
        // print head and deleted the head
        System.out.println("Queue's head: " + queue.remove());
    }
}
Posted by: Guest on September-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language