VOOZH about

URL: https://www.geeksforgeeks.org/java/concurrentlinkeddeque-push-method-in-java-with-examples/

⇱ ConcurrentLinkedDeque push() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ConcurrentLinkedDeque push() method in Java with Examples

Last Updated : 11 Jul, 2025
The push() method of ConcurrentLinkedDeque class is an in-built function in Java which pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. Syntax:
public void push(E e)

Here, E is the type of element maintained 
by this collection class.
Parameter: This method accepts only a single parameter element which is to be added at the head of the ConcurentLinkedDeque. Return Value:The function has no return value. Exception:The method will throw the following exceptions.
  • IllegalStateException: if the element cannot be added at this time due to capacity restrictions.
  • ClassCastException: if the class of the specified element prevents it from being added to this deque.
  • NullPointerException: if the specified element is null and this deque does not permit null elements.
  • IllegalArgumentException: if some property of the specified element prevents it from being added to this deque.
Below programs illustrate the ConcurrentLinkedDeque.push() method: Program 1: This program involves a ConcurrentLinkedDeque of Character type.
Output:
ConcurrentLinkedDeque: [Geeks, For, Geeks, To, Welcome]
Program 2: To show NullPointerException.
Output:
ConcurrentLinkedDeque: []
Trying to add null in ConcurrentLinkedDeque
java.lang.NullPointerException
Comment