import java.util.*;
import java.util.concurrent.*;
import java.util.stream.*;
class Main {
public static void main(String[] args) {
Queue<Integer> queue = IntStream.rangeClosed(1, 5)
.boxed()
.collect(Collectors.toCollection(LinkedList::new));
// add() and offer() add to the end of the queue
queue.add(10);
queue.offer(11);
System.out.println("The queue currently has " + queue);
// poll()/remove() removes from the beginning of the queue
System.out.println(queue.remove());
System.out.println(queue.poll());
System.out.println("The queue finally contains " + queue);
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: