ArrayDeque removeLast() Method in Java
The Java.util.ArrayDeque.removeLast() method is used to remove the last element of the Deque.
Parameters: The method does not take any parameters.
Return Value: This method returns the last element of the Deque after removing it.
Exceptions: The method throws NoSuchElementException if the deque is empty.
Below programs illustrate the Java.util.ArrayDeque.removeLast() method:
Initial ArrayDeque: [Welcome, To, Geeks, For, Geeks] ArrayDeque after removing elements: [Welcome, To]
Initial ArrayDeque: [10, 15, 30, 20, 5] ArrayDeque after removing elements: [10, 15, 30]
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.