Java Deque Operations: Insertion and Removal Methods

Day - 30 : Deque in java 1) Allows insertion and removal of elements from both ends. 2) Versatile than regular queue and stack because they support all operations of both. ● Insertion methods : 1) addFirst : Inserts the specified elements at the front. 2) addLast : Inserts the specified element at the last. 3) offerFirst : Inserts the specified element at the front if possible. 4) offerLast : Inserts the specified element at the end if possible. ● Removal methods : 1) removeFirst () : Retrieves and removes the first element. 2) removeLast () : Retrieves and removes the last element. 3) pollfirst () : Retrieves and removes the first element or returns null if empty. 4) pollLast() : Retrieves and removes the last element or returns null if empty. #Java #CoreJava #coding #programming #learning #Deque

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories