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

Ben picture Ben · Dec 12, 2011 · Viewed 7.3k times · Source

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

Answer

Eng.Fouad picture Eng.Fouad · Dec 12, 2011

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");