Java Deque Interface
The interface called Deque is present in java.util package. It is the subtype of the interface queue. The Deque supports the addition as well as the removal of elements from both ends of the data structure. Therefore, a deque can be used as a stack or a queue. We know that the stack supports the Last In First Out (LIFO) operation, and the operation First In First Out is supported by a queue. As a deque supports both, either of the mentioned operations can be performed on it. Deque is an acronym for "double ended queue".
Deque Interface declaration
Methods of Java Deque Interface
We know that it is not possible to create an object of an interface in Java. Therefore, for instantiation, we need a class that implements the Deque interface, and that class is ArrayDeque. It grows and shrinks as per usage. It also inherits the AbstractCollection class.
The important points about ArrayDeque class are:
The hierarchy of ArrayDeque class is given in the figure displayed at the right side of the page.
ArrayDeque class declaration
Let's see the declaration for java.util.ArrayDeque class.
Java ArrayDeque Example
Ravi Vijay Ajay
Java ArrayDeque Example: offerFirst() and pollLast()
After offerFirst Traversal... jai arvind vimal mukul After pollLast() Traversal... jai arvind vimal
Java ArrayDeque Example: Book
101 Let us C Yashwant Kanetkar BPB 8 102 Data Communications & Networking Forouzan Mc Graw Hill 4 103 Operating System Galvin Wiley 6
Next TopicJava Map Interface