Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java warning - JList is a raw type, references must be parameterized

Can someone shed more light the following warning from Eclipse:

JList is a raw type. References to generic type JList<E> should be parameterized.

A line of code triggering this could be:

import javax.swing.JList;
....
private JList jList = null;  // Warning on this line
like image 282
Ben Avatar asked Dec 12 '11 04:12

Ben


2 Answers

You should put the type of the elements between <>, for example:

List<String> list = new ArrayList<String>();
list.add("String 1");
list.add("Some Text");
like image 196
Eng.Fouad Avatar answered Oct 05 '22 15:10

Eng.Fouad


JList is a raw type as of Java 1.7, the same goes for a couple more of swing components. Your x86 and x64_86 enviroments probably have diferent versions of java, that's why you're getting the warning in one, and no warning in the other.

like image 31
WhyNotHugo Avatar answered Oct 05 '22 16:10

WhyNotHugo