java集合的相关方法

1、将List转化为string(逗号拼接)
共两种方法:

List<String> letters= Arrays.asList("A", "B", "C", "D");
String lettersCommaSeparated = String.join(",", letters);
System.out.println(lettersCommaSeparated );
String lettersCommaSeparated = letters.stream().collect(Collectors.joining(","));
System.out.println(lettersCommaSeparated );

2、stream流
https://blog.csdn.net/qq_36050720/article/details/99829984?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param

你可能感兴趣的:(集合)