Datasets:

ArXiv:
License:
File size: 667 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.*;

public class QueueExample {
    public static void main(String[] args) {
        Queue<String> locationsQueue = new LinkedList<>();
        locationsQueue.add("Kolkata");
        locationsQueue.add("Patna");
        locationsQueue.add("Delhi");
        locationsQueue.add("Gurgaon");
        locationsQueue.add("Noida");
        System.out.println("Queue is : " + locationsQueue);
        System.out.println("Head of Queue : " + locationsQueue.peek());
        locationsQueue.remove();
        System.out.println("After removing Head of Queue : " + locationsQueue);
        System.out.println("Size of Queue : " + locationsQueue.size());
    }
}