Home » Java Deque removeFirst() Method with Examples

Java Deque removeFirst() Method with Examples

by Online Tutorials Library

Java Deque removeFirst() Method

The removeFirst() method of Deque interface is used to retrieve and removes the first element of the given deque. The above method is different from the pollFirst() method such that it throws an exception if the given deque is empty.

Syntax:

Parameter:

NA

Return:

The above method is used to return the head of the given deque.

Throw:

NoSuchElementException– If the given deque is empty.

Example 1

Test it Now

Output:

The removed string is : Welcome  The resultant deque is :   to  our  site  

Example 2

Test it Now

Output:

The removed integer value is : 66  The resultant deque is :   11  33  44  

Example 3

Test it Now

Output:

The removed long value is : 11  The resultant deque is :   88  22  99  
Next TopicJava Deque

You may also like