Reputation: 223
This code doesn't compile:
import java.util.List;
class A {
void foo(List l) { }
}
class B extends A {
void foo(List<?> l) { }
}
However, the following code compiles (foo in D overrides foo in C). Why?
class C {
void foo(List<?> l) { }
}
class D extends C {
void foo(List l) { }
}
Upvotes: 4
Views: 571
Reputation: 23123
The second example compiles because List<> derives from List, but not the other way around which is why the first example doesn't compile.
Upvotes: 2