I completely get this question Method has the same erasure as another method in type and the answer to it. Please can anyone help me understand the below?
Trying hard to digest, why the 2nd code snippet below gives compiler error?
Code 1: Compiles fine
class Parent {
public void set(Collection<Integer> c) { }
}
class Child extends Parent {
public void set(Collection<Integer> c) {}
}
Code 2: Compiler Error at set
method in Child class.
class Parent {
public void set(Collection<?> c) { }
}
class Child extends Parent {
public void set(Collection<Integer> c) {}
}
Compiler Error is
Name clash: The method set(Collection) of type Child has the same erasure as set(Collection) of type Parent but does not override it