ArrayDeque



ArrayDeque is available since Java 1.6

It extends AbstractCollection class.

It implements following interfaces:
Serializable
Colneable
Deque

ArrayDeque has three constructors:
ArrayDeque()
ArrayDeque(Collection c)
ArrayDeque(int numOfElements)

Characteristics:
  • It has not capacity restriction. Though you can define its capacity but It grows as elements are added more than the capacity. 
  • It's default initialCapacity is 16.
  • It is not thread safe.
  • It can be used as both Stack and Queue.
  • It is faster than Stack class if used as Stack. 
  • It is faster than LinkedList when used as Deque.
  • The ierator returned by this class method's is fail-fast.
  • It prohibits null elements. 
Available methods for Queue and Deque:
add(ob)       addLast(ob)
offer(ob)      offerLast(ob)
remove()     removeFirst()
poll()           pollFirst()
element()     getFirst()
peek()         peekFirst()






Available methods for Stack and Deque:
push(ob)     addFirst(ob)
pop()         removeFirst()
peek()         peekFirst()