Hi there.. I need to create a Custom Hashtable extends java.lang.Hashtable and i need to override the get method to achieve the following behavior :
- if the key == null, it will return a new object of the type V
- if the super.get(key) == null, it will also return a new object of type V.
Can anyone help me. I try to do this but I know it's wrong.
import java.util.Hashtable;
public class CustomHashtable<K, V> extends Hashtable {
@Override
public synchronized V get(Object key) {
if(key == null) return new Object();
Object v = super.get(key);
if(v == null){
return new Object();
}
}
}
please see the line :
if(key == null) return new Object();
and the lines :
if(v == null){
return new Object();
}
to know where the error occurred..