类型JList不采用参数类型< String>. [英] type JList does not take parameter type <String>
本文介绍了类型JList不采用参数类型< String>.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试编译一些代码时,我不断遇到这些错误:
When I try to compile some code I keep getting these errors:
CCC.java:21: type javax.swing.JList does not take parameters
JList<String> list;
或:
CCC.java:30: type javax.swing.DefaultListModel does not take parameters
DefaultListModel<String> jobs, DefaultListModel<String> closJ) throws HeadlessException {
当我尝试删除该部分时,我遇到了大约26个相同的错误,我得到了150行错误,任何人都可以帮忙.
I have about 26 of the same error when I try to remove the section i get about 150 lines of errors can anyone help please.
推荐答案
Generics were added to JList in Java 7. Here's an example from the JList documentation:
String[] data = {"one", "two", "three", "four"};
JList<String> myList = new JList<String>(data);
确保您使用的是Java 7 +.
Make sure you're using Java 7+.
这篇关于类型JList不采用参数类型< String>.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文