0
嘿,我正在为一个项目输入部门信息。这些信息包括名称,缩写,位置和成员数量。我有第一个类接受8个参数,(字符串,字符串缩写,字符串,int,int,int,int,int,double)。查找ArrayList中是否存在字符串
它被添加到一个ArrayList中,我无法测试以查看这些类中是否存在字符串缩写。
我有什么作为的方法是:
private ArrayList<DeptInfo> dept = new ArrayList<DeptInfo>();
public boolean deleteDeptInfo(String abbrev) {
boolean result = false;
int index = -1;
for (DeptInfo test : dept) {
if (test.getAbbrev() == abbrev) {
index = dept.indexOf(test);
break;
}
}
if (index >= 0) {
dept.remove(index);
result = true;
}
return result;
}
最新的麻烦? – JungJoo