Javatpoint Logo
Javatpoint Logo

Java Deque peekFirst() Method

The peekFirst() method of Java Deque Interface retrieves and not remove the first element of the given deque. But, if the deque is empty, it may return null.

Syntax:

Parameter:

N.A.

Return:

The above method is used to return the head of the given deque. On the other hand, if the deque is empty, the method may return null.

Example 1

Test it Now

Output:

The first value is given as : Tina
The deque is given as : [Tina, Shyam, Isha, Falguni]

Example 2

Test it Now

Output:

The first integer value is given as : 34
The deque is given as : [34, 43, 22, 55]

Example 3

Test it Now

Output:

The first characater value is given as : H
The final deque is given as : 
H
E
L
L
O
Next TopicJava Deque





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA