0

Here is my code:

class mynode
{
   mynode prev;
   mynode next;
       int value; 
}

class link
{
   List<mynode> pos;
   link(int x)
   {
       pos = new ArrayList<mynode>();
   }
}

I have seen here that using List is better than using ArrayList. So why am I seeing below error?

The type List is not generic; it cannot be parameterized with arguments <mynode>
5
  • 2
    Are you using java.util.List? Commented Aug 27, 2013 at 21:04
  • 2
    I guess you have wrong import. Commented Aug 27, 2013 at 21:04
  • 1
    Most likely you are importing something else than java.util.List Commented Aug 27, 2013 at 21:05
  • 1
    Are you sure you're importing java.util.List? Or are you accidentally using java.awt.List? Commented Aug 27, 2013 at 21:05
  • Oh I was using java.awt.List Commented Aug 27, 2013 at 21:05

1 Answer 1

8

Your code looks fine so I guess you made mistake in import section. Common mistake when you start using IDE like Eclipse is choosing java.awt.List instead of java.util.List from import suggestions. List you want to use comes from java.util package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.