The Java.util.ArrayDeque.removeFirst() method is used to remove the first element of the Deque.
Parameters: The method does not take any parameters.
Return Value: This method returns the first element of the Deque after removing it.
Exceptions: The method throws NoSuchElementException is thrown if the deque is empty.
Below programs illustrate the Java.util.ArrayDeque.removeFirst() method:
Initial ArrayDeque: [Welcome, To, Geeks, For, Geeks] ArrayDeque after removing elements: [For, Geeks]
Initial ArrayDeque: [10, 15, 30, 20, 5] ArrayDeque after removing elements: [30, 20, 5]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.