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

拟墨画扇 提交于 2019-12-08 19:49:45

问题


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

回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/8469945/java-warning-jlist-is-a-raw-type-references-must-be-parameterized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!