In my interface:
public <T> Result query(T query)
In my 1st subclass:
public <HashMap> Result query(HashMap queryMap)
In my 2nd subclass:
public <String> Result query(String queryStr)
1st subclass has no compilation warning at all while 2nd subclass has:
The type parameter String is hiding the type String? I understand my parameter is hidden by the generics type. But I want to understand underneath what exactly happened?
It thinks you’re trying to create a type parameter — a variable — whose name is
String. I suspect your first subclass simply doesn’t importjava.util.HashMap.In any event, if
Tis a type parameter of your interface — which it probably should be — then you shouldn’t be including the<String>in the subclasses at all. It should just be