Java ListIterator nextIndex() 方法

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

ListIterator 接口的 nextIndex() 方法用于返回 next() 方法将要返回的元素的索引。

语法

参数

不适用

返回

上述方法用于返回 next() 方法将要返回的元素的索引。如果列表迭代器位于列表的末尾,该方法也可能返回列表的大小。

示例 1

输出

The vehicles are listed as :[Scooter, Car, Truck, Bike]
The first Index is given as : 0
The second Index is given as : 1
The third index is given as : 2
The fourth index is given as : 3

示例 2

输出

The marks are listed as : [22.4, 34.98, 12.9, 76.4]
The first Index is given as : 0
The second Index is given as : 1
The third index is given as : 2
The fourth index is given as : 3

示例 3

输出

The ages are listed as :[5, 10, 15, 20]
The first Index is given as : 0
The second Index is given as : 1
The third index is given as : 2
The fourth index is given as : 3
下一主题Java ListIterator