GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — Deque Interface in Java - GeeksforGeeks Deque Interface in JavaLast Updated : 24 Apr, 2026 The Deque interface is part of the java.util package and extends the Queue interface. It stands for Double-Ended Queue and represents a linear collection that allows insertion, removal, and retrieval of elements from both ends.
Declaration
Here, E is the type of elements stored in the deque.
Output First: 1, Last: 2 Hierarchy of Deque interfaceIt extends the Queue interface which extends the Collection Interface. It has implementation classes like ArrayDeque and LinkedList. ![]() Common Implementations classes
Deque Operations using ArrayDequeLet’s see how to perform a few frequently used operations on the Deque using the ArrayDeque class. 1. Adding ElementsTo add elements in a Deque, you can use add() , addFirst(), or addLast(), allowing insertion at either end, unlike a standard Queue which only adds at the tail.
Output [Geeks, For, Geeks] 2. Removing ElementsElements can be removed from both ends using removeFirst(), removeLast(), pop(), or poll() variants; pop() throws an exception if empty, while poll() is safe.
Output [Geeks, For, Geeks] Geeks For Geeks null 3. Iterating through the DequeSince a Deque can be iterated from both directions, the iterator method of the Deque interface provides us two ways to iterate. One from the first and the other from the back.
Output Geeks For Geeks is so good is so good Geeks For Geeks Methods of Deque InterfaceBelow are some common list of methods of Deque Interface
Comment Explore | ||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |