I want to implements a generic interface in a class. Consider implementing this generic interface:
public interface Lookup<T>{
public T find(String name);
}
and this is the not generic class that implement Lookup:
public class IntegerLookup implements Lookup<Integer>{
private Integer[] values;
private String[] names;
public IntegerLookup(String[] names, Integer[] values) {......}
//now I want to write the implemented method - find
and my question is: how do I need to write this implemented method? I need to override it? yes?
public Object find(String name){...}
will be good? or:
public Integer find(String name){...}
Tis used in the super type,Integershould be used in the subclass that usesIntegeras a type argument forT.Lookup, has declared the method's return type asT.