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
.
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
.
You are likely importing java.awt.List
.
You should instead import java.util.List
, which is a parameterized type.
awt
package is for building GUIs, so java.awt.List
is a GUI object. java.util.List
is not. –
Ovular 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;
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.
© 2022 - 2024 — McMap. All rights reserved.
List
. It's supposed to bejava.util.List
. – Amadoamador