I have some troubles with a method having a typed List parameter, inherited from another (typed) class.
Let's keep it simple :
public class B<T> {
public void test(List<Integer> i) {
}
}
The B class has a useless generic T, and test() want an Integer List.
Now if I do :
public class A extends B {
// don't compile
@Override
public void test(List<Integer> i) {
}
}
I get a "The method test(List) of type A must override or implement a supertype method" error, that should not happen.
But removing the type of the list works... although it doesn't depend on the class generic.
public class A extends B {
// compile
@Override
public void test(List i) {
And also defining the useless generic below to use the typed list
public class A extends B<String> {
// compile
@Override
public void test(List<Integer> i) {
So I'm clueless, the generic of B should have no influence on the type of the test() list. Does anyone have an idea of what's happening?
Thanks
Void
is used for generic parameters you don't want to use. For instance which usingjava.security.PreivilegedAction
without returning a value (returnnull
- it's the only validVoid
reference). – Haphtarah