How come this compiles:
interface Test {
<T extends Integer> T getValue(T n);
}
class Impl implements Test{
public Integer getValue(Integer n) {
return n;
}
}
But this doesn't:
interface Test {
Integer getValue(Integer n);
}
class Impl implements Test{
public <T extends Integer> T getValue(T n){
return n;
}
}
It gives me the following compile error:
Impl is not abstract and does not override abstract method getValue(Integer) in Test
error: name clash: getValue(T) in Impl and getValue(Integer) in Test have the same erasure, yet neither overrides the other
Doesn't erasure ensure that T gets replaced with Integer? So why would the second example not be valid?