Domanda

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.

È stato utile?

Soluzione

You are likely importing java.awt.List.

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

Altri suggerimenti

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;

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

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top