mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix
This commit is contained in:
parent
7d3f80fbb0
commit
486758b0e3
@ -1964,19 +1964,6 @@ public class CollUtil {
|
||||
return IterUtil.getFirst(iterable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集合的第一个元素
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iterator {@link Iterator}
|
||||
* @return 第一个元素
|
||||
* @see IterUtil#getFirst(Iterator)
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public static <T> T getFirst(final Iterator<T> iterator) {
|
||||
return IterUtil.getFirst(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集合的最后一个元素
|
||||
*
|
||||
|
@ -556,6 +556,9 @@ public class IterUtil {
|
||||
* @since 5.8.0
|
||||
*/
|
||||
public static <E> E get(final Iterator<E> iterator, int index) throws IndexOutOfBoundsException {
|
||||
if(null == iterator){
|
||||
return null;
|
||||
}
|
||||
Assert.isTrue(index >= 0, "[index] must be >= 0");
|
||||
while (iterator.hasNext()) {
|
||||
index--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user