I have this code:
class A {
public void func(String str, List<String> lst) {}
}
class B extends A {
public void func(String str, List<Integer> lst) {} // Does not compile
}
The line with the comment does not compile with the following explanation: "both methods have same erasure yet neither overrides the other". On the one hand, I understand that it is not overriding, since the generic type in the second argument is different. On the other hand, after erasure both functions have essentially the same signature, so it is not overloading either. But I am struggling to understand why it doesn't compile. Any help would be appreciated.
ADDED: Even if I change the signature to
public Object func(String str, List<Integer> lst) {return null;}
It still does not compile, with the same reason. Now these are different signatures altogether, so it makes me even more confused.