S
Sebastian Bossung
Hi all,
I have a problem understanding generics, specifically the use of "super". I
have this code:
protected void methodA(List<? super String> list) {
list.add(new String());
}
Which I think should be legal, because list is declared to be a list of
String or supertype so I should be able to add String instances to it.
Thinks me. But the compiler says that this is an
"Unsafe wildcard operation: The method add(? super String) of type List<?
super String> is not applicable for the arguments (String)".
I am using Eclipse (3.0.0 with JDT Preview plugin and JDK 1.5.0 on Linux).
Thanks for any help!
Sebastian
I have a problem understanding generics, specifically the use of "super". I
have this code:
protected void methodA(List<? super String> list) {
list.add(new String());
}
Which I think should be legal, because list is declared to be a list of
String or supertype so I should be able to add String instances to it.
Thinks me. But the compiler says that this is an
"Unsafe wildcard operation: The method add(? super String) of type List<?
super String> is not applicable for the arguments (String)".
I am using Eclipse (3.0.0 with JDT Preview plugin and JDK 1.5.0 on Linux).
Thanks for any help!
Sebastian