我将一个对象数组从我已经创建的学生类复制到链接列表,但是在第5行,显示以下错误:(“找不到符号 - E类”)
为什么?
import java.util.*;
public class StudentLinkedList
{
private List<E[]> studentLL = new LinkedList<E[]>();
public StudentLinkedList(Student[] st)
{
for(int i = 0; i < st.length; i++)
{
studentLL.add(st[i]);
}
}
}
答案 0 :(得分:5)
你可能想写:
private List<Student> studentLL = new LinkedList<Student>();
代替。
声明此类字段时,指定列表元素的类型。您指定的类型是E
,但编译器不知道任何名称。
答案 1 :(得分:1)
尝试将LinkedList instanciator更改为private List<Student> studentLL= new LinkedList<Student>();