我正在努力使用下面的基本代码,
如何防止最后一个逗号“,”附加到字符串。
String outScopeActiveRegionCode="";
List<String> activePersons=new ArrayList<String>();
HashSet<String> outScopeActiveRegionCodeSet=new HashSet<String>();
for (String person : activePersons) {
outScopeActiveRegionCodeSet.add(person);
}
Iterator itr = outScopeActiveRegionCodeSet.iterator();
while(itr.hasNext()){
outScopeActiveRegionCode+=itr.next();
outScopeActiveRegionCode+=",";
}