![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
stream
进步中的程序猿
这个作者很懒,什么都没留下…
展开
-
JDK8中 stream(流)四种创建方式
1 第一种 通过Collection得Stream()方法(串行流)或者 parallelStream()方法(并行流)创建Stream。List<String> list = Arrays.asList("1","2","3","4","0","222","33");Stream<String> stream = list.stream(); Stream<String> stream1 = list.parallelStream();2 通过Arrays中得原创 2020-07-03 15:44:00 · 536 阅读 · 0 评论 -
使用java8的stream(流)将List集合转成Map集合的方法
常用方式代码如下:public Map<Long, String> getIdNameMap(List<Account> accounts) {returnaccounts.stream().collect(Collectors.toMap(Account::getId, Account::getUsername)); }收集成实体本身map代码如下:public Map<Long, Account> getIdAccountMap(List<Acc原创 2020-07-03 15:48:54 · 36583 阅读 · 0 评论