Pregunta

I have the following code

List<Double> array = new ArrayList<Double>();

This won't compile however because I'm getting an error on List which says "The type list is not generic; it cannot be parameterised with arguments.

I am using Java 7 update 45 and my complile path in eclipse to is JavaSE-1.7 so I thought this should be possible after JDK 5 , does anyone have any suggestions what might be going wrong? My imports are as follows...

import java.awt.List;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Arrays;
¿Fue útil?

Solución

You should add import java.util.List; instead of import java.awt.List;. The former one is generic list, the latter one is display element.

java.awt.List - The List component presents the user with a scrolling list of text items.

java.util.List - An ordered collection (also known as a sequence).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top