Java LinkedBlockingDeque getFirst() method

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

Syntax:

Parameters:

NA

Specified By:

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

Return Value:

The getFirst() method returns the first element of this deque.

Throws:

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

Example 1

Test it Now

Output:

First element in the Queue is : 987

Example 2

Test it Now

Output:

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

Example 3

Test it Now

Output:

Mansi got 41 bonus_points.
Vaibhav got 33 bonus_points.
Shraddha got 31 bonus_points.
Vishal got 27 bonus_points.
Shalu got 26 bonus_points.
Abhi got 19 bonus_points.

On the basis of bonus points, Promotion is awarded to : Mansi





Latest Courses