这是我到目前为止所做的,但我遇到了一行问题:
public class SFHashMap<Key, Value> {
private static int size;
private Entry<Key, Value>[] table;
class Entry<Key, Value> {
Key key;
Value value;
Entry next;
public Entry(Key key, Value value, Entry<Key, Value> next) {
this.key = key;
this.value = value;
this.next = next;
}
}
public SFHashMap() {
this(16);
}
public SFHashMap(int size) {
this.size = size;
table = new Entry[size]; **HERE**
}
}
对于table = new Entry[size];
,我无法将其实例化为new Entry<Key, Value>[size]
,因为我无法创建通用数组。最好的方法是什么?感谢