我是Java新手。 我正在使用Eclipse IDE。我得到一个错误如果@override在那里,而不是@override已被删除。任何人都可以在这方面帮助我。谢谢JAVA - 覆盖
类型HashDictionary的方法remove(K)必须重写一个超类。这是我得到的错误。
public interface DictionaryInterface <K extends Comparable<K>, V>
{
public void insert(K key, V value);
public V getValue(K str);
public void remove(K key);
public K[] getKeys();
}
public class HashDictionary <K extends Comparable<K>, V> implements DictionaryInterface <K,V>{
Hashtable<K,V> h;
Class<K> KeyType;
HashDictionary(Class<K> KeyType) {
h=new Hashtable<K, V>();
this.KeyType=KeyType;
}
public K[] getKeys() {
// TODO Auto-generated method stub
Set<K> s = h.keySet();
K elements[]=(K[])Array.newInstance(KeyType, h.size());
int i=0;
for(K e:s)
{
elements[i]=e;
i++;
}
return elements;
}
@Override
public void remove(K key) {
h.remove(key);
}
@Override
public V getValue(K str) {
return h.get(str);
}
@Override
public void insert(K key, V value) {
h.put(key, value);
}
}
什么是确切的错误信息? – Raptor
您认为使用@Override注释是什么? – Thihara
让我们看看你的'DictionaryInterface' –