【发布时间】:2013-04-13 07:09:44
【问题描述】:
我有两个数组列表,声明为:
ArrayList<JRadioButton> category = new ArrayList<JRadioButton>();
ArrayList<Integer> cat_ids = new ArrayList<Integer>();
这两个字段都包含完全相同的相同数量的值,它们在自然界中实际上是对应的。
我知道我可以像这样遍历其中一个循环:
for(JRadioButton button: category)
{
if(button.isSelected())
{
buttonName = button.getName();
System.out.println(buttonName);
}
}
但是,我想同时遍历这两个 LISTS。我知道它们的尺寸完全相同。我该怎么做?
【问题讨论】:
-
基本上这应该足够了你为什么要迭代ids?
-
您应该尝试在这里使用地图而不是两个列表。
标签: java