Java list 转字符串并加入,分隔符的方法

2019-12-05 18:49:49 浏览数 (1)

代码语言:javascript复制
        List<String> list = new ArrayList<String>();
        list.add("aabbcc");
        list.add("123456");
        System.out.println(list.toString());//[aabbcc, 123456]
        System.out.println(StringUtils.join(list.toArray(), ","));//aabbcc,123456
        System.out.println(String.join(",", list));//aabbcc,123456

0 人点赞