The java.util.concurrent.ConcurrentLinkedDeque.getLast() method is an in-built method in Java which returns the last element of the deque container.
Parameters: The method does not accept any parameter.
Return Value: The method returns the last element present in the Deque.
Exception: The function throws a NoSuchElementException when the deque is empty.
Below programs illustrate the ConcurrentLinkedDeque.getLast() method:
Elements in Deque: [Welcome, To, Geeks, 4, Geeks] The Last element is: Geeks
java.util.NoSuchElementException Elements in Deque: [12, 43, 29, 16, 70] The Last element is: 70
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.