Java LinkedBlockingDeque getLast() method

The getLast() method of LinkedBlockingDeque class returns the last element of this deque but does not withdraw it.

Syntax:

Parameters:

NA

Specified By:

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

Return Value:

The getLast() method returns the last element of this deque.

Throws:

The getLast() method throws NoSuchElementException, if this deque is empty.

Example 1

Test it Now

Output:

Last element in the Queue is : Janak

Example 2

Test it Now

Output:

Exception in thread "main" java.util.NoSuchElementException
	at java.util.concurrent.LinkedBlockingDeque.getLast(Unknown Source)





Latest Courses