1、将string类型集合List<String>转换成string字符串方法
public static String listToString(List<String> stringList) {
if (stringList == null) {
return null;
}
StringBuilder result = new StringBuilder();
boolean flag = false;
for (String string : stringList) {
if (flag) {
result.append(",");
} else {
flag = true;
}
result.append(string);
}
return result.toString();
}
2、将integer类型集合List<Integer>转换成string字符串方法
public static Integer listToInteger(List<Integer> integerList) {
if (integerList == null) {
return null;
}
StringBuilder result = new StringBuilder();
boolean flag = false;
for (Integer integer : integerList) {
if (flag) {
result.append(",");
} else {
flag = true;
}
result.append(integer);
}
return result.length();
}