wam090
wam090

Reputation: 2873

A question about Linked List

Im copying an array of objects to the linked list from a student class that i already made, but in the 5th line , the following error is showing : (" cannot find symbol - class E ")

Why is that?

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]);
        }

    }
}

Upvotes: 0

Views: 250

Answers (2)

Jason
Jason

Reputation: 11363

Try changing the LinkedList instanciator to private List<Student> studentLL= new LinkedList<Student>();

Upvotes: 1

Grzegorz Oledzki
Grzegorz Oledzki

Reputation: 24251

You probably wanted to write:

private List<Student> studentLL = new LinkedList<Student>();

instead.

When declaring such a field, you specify the type of the elements of a list. The type you have specified is E, but the compiler doesn't know anything called that.

Upvotes: 5

Related Questions