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 import java.util.HashMap
.
In any event, if T
is 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
public interface Interface<T> {
public Result query(T query);
}
public class Subclass implements Interface<String> {
...
public Result query(String queryStr) {
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With