Java Deque getFirst() Method

The getFirst() method of Java Deque Interface retrieves but does not remove the first element of the given deque. The above method differs from peekFirst only in one way that it throws an exception if the deque is empty.

Syntax:

Parameter:

NA

Return:

The above method returns the head of the deque.

Example 1

Test it Now

Output:

The list of the elements is given as : 
[44.0, 66.0, 11.0, 99.0]
The final result of the deque is given as : 44.0

Example 2

Test it Now

Output:

The list of the elements is given as : 
[k, p, m, t]
The final result of the deque is given as : k
Next TopicJava Deque




Latest Courses