第三行代码有警告,请问怎样去除。报错信息我注释在了警告行上面。class MyHashMap<K, V> { public static final int SIZE = 1000; //Type safety: The expression of type MyHashMap.Entry[] needs unchecked conversion to conform to MyHashMap.Entry<K,V>[] public Entry<K, V>[] tables = new Entry[SIZE]; public void put(K key, V value) { int index = key.hashCode() % SIZE; while(tables[index] != null) { index++; } tables[index] = new Entry<K, V>(); tables[index].key = key; tables[index].value = value; tables[index].hash = key.hashCode(); } public V get(K key) { int index = key.hashCode() % SIZE; while(tables[index] != null && key.hashCode() != tables[index].hash &&!key.equals(tables[index].key)) { index++; } return tables[index].value; } static class Entry<K, V> { int hash; K key; V value; }}
添加回答
举报
0/150
提交
取消