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.
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.
ConcurrentLinkedDeque: [Geeks, For, Geeks, To, Welcome]
Program 2: To show NullPointerException.
ConcurrentLinkedDeque:  Trying to add null in ConcurrentLinkedDeque java.lang.NullPointerException
- ConcurrentLinkedDeque pop() method in Java with Examples
- ConcurrentLinkedDeque contains() method in Java with Examples
- ConcurrentLinkedDeque remove() method in Java with Examples
- ConcurrentLinkedDeque offer() method in Java with Examples
- ConcurrentLinkedDeque addAll() method in Java with Examples
- ConcurrentLinkedDeque Spliterator() method in Java with Examples
- ConcurrentLinkedDeque isEmpty() method in Java with Examples
- BlockingDeque push() method in Java with examples
- ConcurrentLinkedDeque in Java with Examples
- ConcurrentLinkedDeque add() method in Java
- ConcurrentLinkedDeque toArray() method in Java with Example
- ConcurrentLinkedDeque size() method in Java
- ConcurrentLinkedDeque addFirst() method in Java
- ConcurrentLinkedDeque getFirst() method in Java
- ConcurrentLinkedDeque offerFirst() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.