需求:向数组或list中添加一个数值,判断如果该数值已经存在,那么+1,继续想数组或list中添加,如果还存在则继续+1,直至该数值原数组或list中不存在位置
解决:List<String> acIdList = new ArrayList<String>();
for(int i=0;i<indexList.size();i++){
if(!indexList.get(i).getAcId().trim().isEmpty()){
acIdList.add(indexList.get(i).getAcId());
}
}
while(acIdList.contains(acId)){
count++;
acId=flagZm+flagRq+df.format(count);
}
acId就是要产生的值