error: type List does not take parameters
Asked Answered
P

3

41

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.

Pricefixing answered 9/4, 2014 at 7:25 Comment(1)
You're importing the wrong List. It's supposed to be java.util.List.Amadoamador
O
113

You are likely importing java.awt.List.

You should instead import java.util.List, which is a parameterized type.

Ovular answered 9/4, 2014 at 7:27 Comment(2)
Thanks, it works. But what is the difference and how a newcomer to Java is supposed to know one?Pricefixing
@ror6ax The awt package is for building GUIs, so java.awt.List is a GUI object. java.util.List is not.Ovular
L
7

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;
Leninist answered 9/4, 2014 at 7:27 Comment(0)
L
0

I am getting solved this problem by renaming the class name or file name as in Notepad++.

You Should not take the class names as ArrayList or List. And you also need to add the following package

import java.util.*;

My Previous class name is List I changed it into the Names.so You have to change the class name.

Laurentian answered 18/1, 2022 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.