Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "type List does not take parameters" in Netbeans?

Tags:

java

csv

netbeans

I tried this code but i'm getting error at List<String[]> (in netbeans)

Error: "type List does not take parameters"

CSVReader csvReader = new CSVReader(new FileReader(new File("file.csv")));
List<String[]> list = csvReader.readAll();
String[][] dataArr = new String[list.size()][];
dataArr = list.toArray(dataArr);

Please any one help solving this problem.

like image 881
mani kumar Avatar asked Sep 24 '15 09:09

mani kumar


2 Answers

You're using java.awt.List that doesn't take a parameter - that's why you're getting "type List does not take parameters" error, you should use java.util.List instead:

java.util.List<String[]> list = csvReader.readAll();

Or simply import from the correct package.

like image 134
Maroun Avatar answered Oct 16 '22 23:10

Maroun


Assuming that you're using OpenCSV, the following works for me without an issue:

java.util.List<String[]> list = csvReader.readAll();

As per the comment already, this almost certainly means you're importing the wrong List class (so check your imports at the top of the source file.) The most likely mixup is java.awt.List.

like image 28
Michael Berry Avatar answered Oct 17 '22 00:10

Michael Berry