Java ListIterator previous() 方法

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

ListIterator 接口的 previous() 方法用于返回列表中的上一个元素,并将光标向后移动。上述方法可用于向后遍历列表。

语法

参数

不适用

返回

上述方法用于返回给定列表的上一个元素。

抛出

NoSuchElementException - 如果给定迭代没有这样的上一个元素。

示例 1

输出

The list of alphabets is given as : [88, 67, 57]
In the forward direction : 
88
67
57
In the backward direction:-
57
67
88

示例 2

输出
The list of electrical appliances is given as : [Fan, Tubelight, Bulb, Television]
In the forward direction : 
Fan
Tubelight
Bulb
Television
In the backward direction:- 
Television
Bulb
Tubelight
Fan

示例 3

输出

The list of alphabets is given as : [R, E, A, L]
In the forward direction : 
R
E
A
L
In the backward direction:- 
L
A
E
R
下一主题Java ListIterator