📄 arrayiterator.java
字号:
package jss.bag;
import java.util.*;
public class ArrayIterator implements Iterator {
private int count;
private int current;
private Object[] items;
public boolean hasNext() {
return (current < count);
}
public ArrayIterator(Object[] collection, int size) {
items = collection;
count = size;
current = 0;
}
public Object next() {
if (!hasNext())
throw new NoSuchElementException();
current++;
return items[current - 1];
}
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -