Summary: | 1.5 generics don't fully support polymorphism | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Alan Malloy <alan> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.1 M2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Alan Malloy
2004-08-30 03:17:04 EDT
You cannot pass in a TreeSet since it expects a Set. Read up on subtypes &
generics.
java version "1.5.0-rc", build 1.5.0-rc-b63 complains with:
test.java:5: incompatible types
found :
java.util.TreeMap<java.lang.String,java.util.TreeSet<java.lang.String>
>
required: java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
Map<String, Set<String>> m = new TreeMap<String,
TreeSet<String>
>();
^
1 error
A workaround for the original poster would be to declare Map<String, ? extends Set<String>> m |