我有一个组合框,其中存储“计算机,代码:21”,“历史记录,代码:31”,并且可以更改项目的数量。但是当我编写此代码以获取其项目时:
List<String> bIHELessons = new ArrayList<String>();
for (int i=0;i<jComboBox1.getItemCount();i++) {
String lessons = (String) jComboBox1.getItemAt(i);
if (lessons != null&& lessons.trim().length()!=0) {
bIHELessons.add(lessons);
System.out.println(bIHELessons.toString());
}
}
它将在控制台中显示这些句子:
[电脑,代码=21]
[计算机,代码=21,历史,代码:31]