error: type List does not take parameters

2019-01-14 06:10发布

问题:

I get the following error despite it's exactly one used in examples:

error: type List does not take parameters

List<String> strings_wat = new ArrayList<String>();

Java is version 1.7 and the class is NOT named ArrayList.

回答1:

Likely you are importing java.awt.List instead of java.util.List



回答2:

It seems like you are importing it from java.awt:

import java.awt.List;

and it looks like you want to use the one from java.util:

import java.util.List;


回答3:

if you are working on Graphical user interface you have to import java.awt.List instead of import java.util.List Other then else if you are working on simple code you have to import java.util.List; instead of import java.awt.List