简体   繁体   中英

Getting “not generic” error when attempting to use List<> In Java

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM