The java.util.concurrent.ConcurrentLinkedDeque.peekLast() is an in-built method in Java which
retrieves the last element of this deque container without removing it. The function returns NULL if the deque is empty.
Parameters: The function does not accepts any parameter.
Return Values: The function returns the last element present in this deque and returns NULL when the deque is empty.
Below programs illustrate the use of peekLast() method:
Program 1: This program involves deque with Integer elements.
Elements inthe LinkedDeque: [76, 55, 110, 12] Last Element inthe LinkedDeque: 12
Program 2: This program involves deque with String elements.
Elements inthe LinkedDeque: [Geeks, GeeksforGeeks, Gfg, GFG] Last Element inthe LinkedDeque: GFG
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.