B
Benjamin Lerman
Hi all,
I've got a weird problem with generics and maps.
I have the 2 following lines :
Collection<? extends ParametresGeneraux> l = new TreeSet<ParametresGlobaux>();
Map<String,Collection<? extends ParametresGeneraux> > m = new TreeMap<String, TreeSet<ParametresGlobaux>>();
The first one causes no problem, the second one causes this error:
Type mismatch: cannot convert from TreeMap<String,TreeSet<ParametresGlobaux>> to Map<String,Collection<? extends ParametresGeneraux>>
Knowing that ParametresGlobaux extends ParametresGeneraux and TreeSet
implements Collection, I don't really see what is wrong.
Is this a misfeature of Generics, or is there any way to have this work
(other than recreating my map).
Thanks.
I've got a weird problem with generics and maps.
I have the 2 following lines :
Collection<? extends ParametresGeneraux> l = new TreeSet<ParametresGlobaux>();
Map<String,Collection<? extends ParametresGeneraux> > m = new TreeMap<String, TreeSet<ParametresGlobaux>>();
The first one causes no problem, the second one causes this error:
Type mismatch: cannot convert from TreeMap<String,TreeSet<ParametresGlobaux>> to Map<String,Collection<? extends ParametresGeneraux>>
Knowing that ParametresGlobaux extends ParametresGeneraux and TreeSet
implements Collection, I don't really see what is wrong.
Is this a misfeature of Generics, or is there any way to have this work
(other than recreating my map).
Thanks.