提取男生string合并用,号分割

 1 /**
 2      * Collectors过滤抽取合并字符串测试.
 3      *
 4      * @param streamBeanList
 5      */
 6     public void testCollectors(List<StreamBean> streamBeanList) {
 7  
 8         if (CollectionUtils.isNotEmpty(streamBeanList)) {
 9  
10             // 所有男性的姓名合并字符串用逗号分隔.
11             String collect = streamBeanList.stream().filter(item -> item.getSex().equals("男")).map(item -> item.getName()).collect(Collectors.joining(", "));
12  
13             System.out.println(collect);
14         }
15  
16     }

 

posted @ 2021-05-31 17:26  小拐  阅读(52)  评论(0)    收藏  举报