Java Deque Interface

Java Deque Interface is a linear collection that supports element insertion and removal at both ends. Deque is an acronym for "double ended queue".

Deque Interface declaration

Method

boolean add(object It is used to insert the specified element into this deque and return true upon success.

boolean offer(object) It is used to insert the specified element into this deque.

Object remove() It is used to retrieves and removes the head of this deque.

Object poll() It is used to retrieves and removes the head of this deque, or returns null if this deque is empty.

Object element() It is used to retrieves, but does not remove, the head of this deque.

Object peek() It is used to retrieves, but does not remove, the head of this deque, or returns null if this deque is empty.

ArrayDeque class

The ArrayDeque class provides the facility of using deque and resizable-array. It inherits AbstractCollection class and implements the Deque interface.

ArrayDeque class declaration

public class ArrayDeque extends AbstractCollection implements Deque, Cloneable, Serializable

EXAMPLE

Flash Soon



Advertisement

Copyright ©2017 Design& develop