字符串数组或集合转化字符串 以逗号分隔

 
import org.apache.commons.lang.StringUtils;


public class Test {

    public static void main(String[] args){

        String[] str = {"a","b","c","d","e"};
        String join = StringUtils.join(str, ",");
        System.out.println(join); //a,b,c,d,e
        String str2 = String.format("%s,%s,%s", str);
        System.out.println(str2); //a,b,c
        List errClassList = Arrays.asList("a","a","a","a");
        String join1 = StringUtils.join(errClassList, ",");
        System.out.println(join1);//a,a,a,a
    }
}
 
 

你可能感兴趣的:(记录)