[英]Java collection Type mismatch: cannot convert from TreeSet to SortedSet
package collection;
import java.util.*;
public class SortedSet {
public static void main(String[] args) {
// TODO Auto-generated method stub
SortedSet set = new TreeSet();
}
}
It giving me following error: 它给了我以下错误:
Type mismatch: cannot convert from TreeSet to SortedSet
Your class name is also SortedSet
, so it is hiding java.util.SortedSet
. 您的类名也是
SortedSet
,因此它隐藏了java.util.SortedSet
。 Either rename your class (the preferred option) or use the full name of the interface in your variable declaration. 重命名您的类(首选选项)或在变量声明中使用接口的全名。
你有两个选择: - 更改类的名称, - 将set的类型更改为TreeSet,如TreeSer set = new TreeSet();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.