java queue remove

Solutions on MaxInterview for java queue remove by the best coders in the world

showing results for - "java queue remove"
Erwann
17 Jan 2020
1
2import java.util.*;
3  
4public class QueueDemo {
5    public static void main(String[] args)
6        throws IllegalStateException
7    {
8  
9        // create object of Queue
10        Queue<Integer> queue
11            = new LinkedList<Integer>();
12  
13        // Add numbers to end of Queue
14        queue.add(1);
15        queue.add(2);
16        queue.add(3);
17        queue.add(4);
18  
19        // print queue
20        System.out.println("Queue: " + queue);
21  
22        // print head and deletes the head
23        System.out.println("Queue's head: " + queue.remove());
24  
25        // print head and deleted the head
26        System.out.println("Queue's head: " + queue.remove());
27    }
28}