1.使用谷歌的Joiner转换

    public static String parseListToStr(List list){ String result = Joiner.on(“,”).join(list); return result; }

    2.使用lambda表达式遍历集合

    public static String parseListToStr2(List list){ StringBuffer sb = new StringBuffer(); list.stream().forEach(str->{ sb.append(str).append(“,”); }); sb.deleteCharAt(sb.length()-1); return sb.toString(); }

    3.直接使用stream流实现

    public static String parseListToStr3(List list){ String result = list.stream().map(String::valueOf).collect(Collectors.joining(“,”)); return result; }