当我尝试编译这个时:
import java.util.*;
public class NameIndex
{
private SortedMap<String,SortedSet<Integer>> table;
public NameIndex()
{
this.table = new TreeMap<String,TreeSet<Integer>>();
}
}
我得到:
Incompatible types - found java.util.TreeMap<java.lang.String,java.util.TreeSet<java.lang.Integer>> but expected java.util.String,java.util.SortedSet<java.lang.Integer>>
知道为什么吗?
更新:这编译:
public class NameIndex
{
private SortedMap<String,TreeSet<Integer>> table;
public NameIndex()
{
this.table = new TreeMap<String,TreeSet<Integer>>();
}
}