我有这样一段代码:的foreach循环语法错误
private V[] elements;
public int size(){
int returnValue = 0;
for(TableEntry<K,V> pointer : elements){
while(pointer != null){
returnValue++;
pointer = pointer.next;
}
}
return returnValue;
}
我得到错误:
Type mismatch: cannot convert from element type V to SimpleHashtable.TableEntry in foreach line.
下面是完整的类:Code
元素是'V',不是的'TableEntry'数组的数组... –
assylias
是TableEntry哈希表的一些子类? – Gacci
你的问题不是关于for循环,而是关于你如何在你的代码中混合使用V和TableEntry。您需要选择其中一个或另一个...... – assylias