Java LinkedBlockingDeque peekLast() Method

The peekLast() method of LinkedBlockingDeque class retrieves this deque's last element, but doesn't remove it. The method returns null if this deque is empty.

Syntax:

Parameters:

NA

Specified By:

The peekLast () method of LinkedBlockingDeque class is specified by peekLast() method in interface Deque<E>.

Return Value:

The peekLast () method returns this deque's tail, and returns null if this deque is empty.

Example 1

Test it Now

Output:

Last element of deque  : 943
Deque after peekLast() : [412, 556, 654, 732, 879, 943]

Example 2

Test it Now

Output:

Last element of deque1  : Nitin
Deque1 after peekLast() : [Keshav, Naveen, Neha, Hitesh, Surbhi, Nitin]

Last element of deque2  : Riya
Deque2 after peekLast() : [Ankit, Megha, Janak, Riya]

Example 3

Test it Now

Output:

Last element of deque  : null
Deque after peekLast() : []





Latest Courses