java容器小问题

来源:百度知道 编辑:UC知道 时间:2024/06/25 07:49:34
class Key
{

}
class Node
{
LinkedList<Key> k=new LinkedList()<Key>;
}

书上容器是这么用的,可是我在eclispe中这么写,可是在写那对<>,人家说不对,这可怎么办呀。

这是JDK1.5及以后才能使用的,你点工程->properties->Java Compiler看下你的编译器版本是多少 如果是5以前的话 这种类型安全检查的新特性是不能用的
解决方法有两种:
1:选择JDK版本到5以上
2:把<Key>去掉

LinkedList<Key> k=new LinkedList()<Key>() ;
少了括号