current position:Home>Convert the contents of the Java list into comma separated strings

Convert the contents of the Java list into comma separated strings

2022-01-27 00:11:28 bjhxcc

Often used in actual projects

Method 1

String symbol = Joiner.on(",").join(symbolList);

Method 2:

String symbol = StringUtils.join(symbolList.toArray(), ",");

To replace the following method

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

copyright notice
author[bjhxcc],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270011260765.html

Random recommended