public static String listToString(List<String> stringList){
if (stringList==null) {
return null;
}
StringBuilder result=new StringBuilder();
result.append("(");
boolean flag=false;
for (String string : stringList) {
if (flag) {
result.append(",");
}else {
flag=true;
}
result.append("‘");
result.append(string);
result.append("‘");
}
result.append(")");
return result.toString();
}
public static void main(String[] args) {
List<String> list=new ArrayList<String>();
list.add("aaa");
list.add("bbb");
list.add("ccc");
System.out.println(listToString(list));//aaa,bbb,ccc
}
时间: 2024-10-10 09:02:17