Java Deque peekFirst() 方法

2025 年 3 月 22 日 | 阅读需 2 分钟

Java Deque 接口的 peekFirst() 方法检索但不移除给定双端队列的第一个元素。但是,如果双端队列为空,它可能返回 null。

语法

参数

不适用。

返回

上述方法用于返回给定双端队列的头部元素。另一方面,如果双端队列为空,该方法可能返回 null。

示例 1

输出

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

示例 2

输出

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

示例 3

输出

The first characater value is given as : H
The final deque is given as : 
H
E
L
L
O
下一主题Java Deque