赞
踩
eg: List entityList = xxxx.getAllList();
1.forEach循环list
entityList .forEach( listBean -> { Integer id = listBean.getId(); Integer actId = listBean.getActId(); String name = listBean.getName(); // listBean.setTitle("为title赋值新值"); ...... } ) 或 for(ListBean listBean : b){ Integer id = b.getId(); Integer actId = b.getActId(); String name = b.getName(); // b.setTitle("为title赋值新值"); }
2.获取list中的指定数据
1.获取listBean集合中所有actId = x 的数据集合
List<Xxxx> firstListBeans = new ArrayList<>();
firstListBeans = listBean.stream().filter(vsList-> vsList.getActId() == x).collect(Collectors.toList());
2.去除entityLists1中与entityLists2中name不相同的值的数据
List<ListBean> entityLists1 = xxxx.getAllList();
List<ListBean> entityLists2 = xxxx.getList(name);
final List<ListBean>[] finalListBeans = new List[]{entityLists2 };
entityLists1 .forEach(entityList1 ->{
finalListBeans[0] = finalListBeans[0].stream().filter(entityList2 -> entityList1.getName != entityList2.getName).collect(Collectors.toList());
});
//去除相同name值后的集合数据
List<ListBean> entityLists3 = finalListBeans[0];
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。