list中内容转化为逗号分隔的字符串

实际项目经常用到的

方法1
String symbol = Joiner.on(",").join(symbolList);
方法2:
String symbol = StringUtils.join(symbolList.toArray(), ",");

用来代替下面的方法

 StringBuffer sb = new StringBuffer();
 for(Object _symbol : symbolList){
      sb.append("'").append(_symbol).append("',");
 }

猜你喜欢

转载自blog.csdn.net/weixin_40205234/article/details/86611398