Java Stream API进阶篇

参考:

https://www.cnblogs.com/CarpenterLee/p/6550212.html

写的很好,

使用collect做字符串join,真的是过目不忘 0.0

// 使用Collectors.joining()拼接字符串
Stream<String> stream = Stream.of("I", "love", "you");
//String joined = stream.collect(Collectors.joining());// "Iloveyou"
//String joined = stream.collect(Collectors.joining(","));// "I,love,you"
String joined = stream.collect(Collectors.joining(",", "{", "}"));// "{I,love,you}"

 

posted @ 2020-05-14 09:22  timetellu  阅读(135)  评论(0编辑  收藏  举报