规律字符串拼接
推荐写法1:使用Java8提供的String.join拼接
推荐写法2:使用Java8提供的StringJoiner类拼接
StringJoiner stringJoiner = new StringJoiner(",", "[", "]");
strList.forEach(str -> stringJoiner.add('"' + str + '"'));
推荐写法3:使用Java8函数式Collectors.joining拼接
String result = strList.stream().collect(Collectors.joining(",", "[", "]"));
推荐写法4:使用Apache的StringUtils.join拼接
StringUtils.join(names, ",");