java修复HashMap中的ClassCastException
嘿,伙计们,我正试图初始化这段代码ClassCastException。 我读了一点,但我似乎不明白为什么我的代码不起作用
public MyHash(HashFunction<KeyType> h1, HashFunction<KeyType> h2){
this.hash1 = h1;
this.hash2 = h2;
this.arr = (Node<KeyType, ValueType>[])new Object[DEFAULT_ARRAY_SIZE];
}
private static class Node<KeyType, ValueType>{}
# 1 楼答案
通过以下方法快速修复:
这个。arr=新节点[默认数组大小]