我收到错误“迭代器无法解析为类型”。我正在尝试采用存储类,并添加实现Java的Collections类所需的代码。我不认为我可以导入Iterator,我认为我需要自己做。
public class storage {
private Object[] data = new Object[256];
// Don't allow access to anything not yet stored
private int nextEmptySlot = 0;
private int i=0;
public Object begin(){
return data[0];
}
public Object end(){
return data[nextEmptySlot];
}
//class Iterator() {
// public Storage data;
//}
public Iterator iterator() {
// returns a class that iterates over the data array
return new Iterator() {
public Object remove(){
for(int j=i+1 ; j<=nextEmptySlot-1 ; j++) {
this.data[j-1] = this.data[j];
} …Run Code Online (Sandbox Code Playgroud)