【MapSheep】
[好记性不如烂笔头]
package com.sjh.test.java8;
 
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
public class JoniningDemo1 {
 
    public static void main(String[] args) {
        List<String> list = Arrays.asList("JayLa","LayMan","KangKang","XinYI");
        String resultStr = list.stream().collect(Collectors.joining());
        System.out.println(resultStr);
        resultStr= list.stream().collect(Collectors.joining(","));
        System.out.println(resultStr);
        resultStr= list.stream().collect(Collectors.joining("-","[","]"));
        System.out.println(resultStr);
    }
}
// 输出
// JayLaLayManKangKangXinYI
// JayLa,LayMan,KangKang,XinYI
// [JayLa-LayMan-KangKang-XinYI]
posted on 2022-06-27 17:09  (Play)  阅读(161)  评论(0编辑  收藏  举报