首页 > 编程语言 >java8新特性之List处理

java8新特性之List处理

时间:2023-02-07 08:57:17浏览次数:55  
标签:toList Collectors stream List 特性 filter collect java8

1.集合中获取指定的一个属性值

List<String> items = li.stream().map(ScdCostChargeItemEntity::getItem).collect(Collectors.toList());

 

2.集合分组

Map<String, List<T>> yearData = allData.stream().collect(Collectors.groupingBy(T::getYear));

 

2.集合过滤筛选(单条件):

List<T> filterList = appleList.stream().filter(a -> a.getName().equals("YC")).collect(Collectors.toList());

 

3.集合过滤筛选(多条件):

List<T> filterList = dayVoList.
stream().filter(a -> a.getYEAR().equals(item)).collect(Collectors.toList())
.stream().filter(a -> a.getPrice() != "0" && a.getPrice() != "0.0").collect(Collectors.toList());

 

标签:toList,Collectors,stream,List,特性,filter,collect,java8
From: https://www.cnblogs.com/RedOrange/p/17091613.html

相关文章

  • List<Map<String, Object>> 去出重复
    List<Map<String,Object>>去出重复publicstaticvoidmain(String[]args){String[]array={"name","age"};List<Map<String,Object>>oldList=getTe......
  • JMM与线程三大特性
    并发与并行并发在早期单核CPU中,没办法同时运行多条指令,只能将多个应用程序分成不同的时间片,由于时间片切换的速度很快,所以看起来就像是多个应用程序同时运行。并发就是一......
  • java8中时间的各种转换(LocalDateTime)
      java8中时间的各种转换(LocalDateTime)1.将LocalDateTime转为自定义的时间格式的字符串publicstaticStringgetDateTimeAsString(LocalDateTimelocalDateTime......
  • JavaSE4️⃣OOP - 三大特性
    1、封装1.1、简介封装(Encapsulation)含义:将数据和基于数据的操作封装在一起,构成一个不可分割的独立实体。将对象的状态信息隐藏在内部,提供公共接口对外提供该对象......
  • javaScript - 函数,函数的定义与函数的特性,函数的内置对象
    1.函数的定义//方式1无参无返回值函数functionclose(){}//方式2有参有返回值函数functionset(id,name){returnid+name;}//方式3匿名函数varcallback=......
  • 【原创】在 VBScript 中使用动态数组(ArrayList)
    环境要求WindowsXP及以上。Windows10、Windows11在Windows功能中勾选.NETFramework3.5(包括.NET2.0和3.0)。优点相比VBScript内置的数组,大小......
  • list使用1
    #include<iostream>#include<list>usingnamespacestd;voidPrintListContents(constlist<int>&listInput);intmain(){list<int>a;//在链表前添加数据......
  • SpringBoot+MyBatis的动态SQL、使用动态SQL时List传值错误解决方案
    目录实现动态SQL的四种方式:1、XML配置2、脚本SQL3、在方法中构建SQL4、结构化SQL关于动态SQL的List传值错误问题1、错误代码2、解决错误实现动态SQL的四种方式:1、XML配置......
  • JOSN字符串转List<dto>方法
    1.引入的包importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.JSONObject;实际代码StringpaperContent=workHistory.getPaperContent(......
  • Redis常用命令之操作List类型
    场景Centos中Redis的下载编译与安装(超详细):霸道的程序猿获取编程相关电子书、教程推送与免费下载。实现List类型是一个链表结构的集合,其主要功能有push、pop、获取元素等......