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