The Java Collections Framework provides Queue interface and its implementation classes as shown in Figure 1 which enable usage of queue data structure in a variety of ways. The interfaces and classes highlighted in this figure are part of Concurrency API.
Figure 1. Queue Interfaces and Classes in Java Collections Framework
This interface extends Collection interface and exists since Java 5. It provides methods to insert, remove or inspect elements in First In First Out (FIFO) or Last In First Out (LIFO) way.
The offer(e) method is used to add elements. It returns true if the element […]