82
Java Deque removeLast() Method
The removeLast() method of Java Deque interface is used to retrieve and removes the last element of the given deque. The above method is different from the pollLast() method such that it throws an exception if the given deque is empty.
Syntax:
Parameter:
NA
Return:
The above method is used to return the tail of the given deque.
Throw:
NoSuchElementException– If the given deque is empty.
Example 1
Output:
The value that needs to be removed is : World The final deque is : Welcome to my
Example 2
Output:
The value that needs to be removed is : E The final deque is : W E B S I T
Example 3
Output:
The value that needs to be removed is : 98.7 The final deque is : 55.9 22.5 77.0
Next TopicJava Deque