【发布时间】:2013-10-16 16:46:34
【问题描述】:
我有一个String 数组和一个List<String>。我想要做的是使用更大尺寸的变量并将其用作移除较小变量的值的基础。我还想获得另一个中不存在的较大变量的值。请注意,这两个变量在数据类型上不同的原因是因为String[] group 变量是来自 jsp 页面的复选框组,而List<String> existingGroup 是来自数据库的 ResultSet。例如:
String[] group 包含:
Apple
Banana
Juice
Beef
List<String> existingGroup 包含:
Apple
Beef
Lasagna
Flower
Lychee
并且由于两个变量的大小不同,它仍然应该正确地删除值。
到目前为止我所拥有的是
if(groupId.length >= existingGroup.size()) {
for(int i = 0; i < groupId.length; i++) {
if(! existingGroup.contains(groupId[i])) {
if(existingGroup.get(existingGroup.indexOf(groupId[i])) != null) {
// I'm unsure if I'm doing this right
}
}
}
} else {
for(int i = 0; i < existingGroup.size(); i++) {
// ??
}
}
谢谢。
【问题讨论】:
-
请参阅此 Stack Overflow 帖子以获取 more clarity