我试图使用我的自定义类与迭代器,但它不能迭代使用的元素foreach.我怎么处理它?
public class FCSOfOtherClass<Double> {
private int n;
private Double[] a;
public FCSOfOtherClass(int cap) {
a = (Double[]) new Object[cap];
}
public void push(Double dou) {
if (a.length == n) {
this.resize(2 * a.length);
a[n++] = dou;
} else {
a[n++] = dou;
}
}
private void resize(int max) {
Double[] newa = (Double[]) new Object[max];
for (int i = 0; i < n; i++) {
newa[i] = a[i];
a = newa;
}
}
public Boolean isEmpty() { …Run Code Online (Sandbox Code Playgroud)