Java Deque peekLast() 方法

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

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

语法

参数

不适用

返回

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

示例 1

输出

The last character is given as : A
The final deque is given as : 
J
A
V
A

示例 2

输出

The last string value is given as : language
The final deque is given as : [Java, is, a, secured, language]

示例 3

输出

The last integer value is given as : 5
The final deque is given as : 
1
2
3
4
5
下一主题Java Deque