Java Deque getFirst() 方法

2025年3月22日 | 阅读1分钟

Java Deque 接口的 getFirst() 方法检索给定双端队列的第一个元素,但不移除它。上述方法与 peekFirst() 的唯一区别在于,如果双端队列为空,它将抛出异常。

语法

参数

不适用

返回

上述方法返回双端队列的头部。

示例 1

输出

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

示例 2

输出

The list of the elements is given as : 
[k, p, m, t]
The final result of the deque is given as : k
下一主题Java Deque