Java 错误:类型列表不带参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22955621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 19:36:43  来源:igfitidea点击:

error: type List does not take parameters

javalistcompiler-errorsgeneric-type-argument

提问by

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.

Java 是 1.7 版,该类未命名ArrayList

采纳答案by BackSlash

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

您可能正在导入java.awt.List而不是java.util.List

回答by Christian

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

似乎您是从java.awt以下位置导入它的:

import java.awt.List;

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

看起来您想使用以下内容java.util

import java.util.List;

回答by Bilal Mustafa

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

如果你正在处理图形用户界面,你必须 import java.awt.List而不是import java.util.List其他,否则如果你正在处理简单的代码,你必须import java.util.List;而不是import java.awt.List