Generics can be used with Deque.
Deque<Object> deque = new LinkedList<Object>();
When a deque is used as a queue, FIFO (First-In-First-Out) behavior results.
Deques can also be used as LIFO (Last-In-First-Out) stacks.
For more information about methods, go through this Documentation.
Deque deque = new LinkedList();
//Adding element at tail
deque.add("Item1");
//Adding element at head
deque.addFirst("Item2");
//Adding element at tail
deque.addLast("Item3");
//Retrieves and removes the head of the queue represented by this deque
Object headItem = deque.remove();
//Retrieves and removes the first element of this deque.
Object firstItem = deque.removeFirst();
//Retrieves and removes the last element of this deque.
Object lastItem = deque.removeLast();
//Retrieves, but does not remove, the head of the queue represented by this deque
Object headItem = deque.element();
//Retrieves, but does not remove, the first element of this deque.
Object firstItem = deque.getFirst();
//Retrieves, but does not remove, the last element of this deque.
Object lastItem = deque.getLast();
//Using Iterator
Iterator iterator = deque.iterator();
while(iterator.hasNext(){
String Item = (String) iterator.next();
}
//Using For Loop
for(Object object : deque) {
String Item = (String) object;
}