标签:imp Collector image stl 图片 for int ima lis
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class ListLamda {
public static void main(String[] args) {
List<Map<String,Object>> list = new ArrayList<>();
for(int i= 0;i<10;i++) {
Map<String, Object> one = new HashMap<>();
one.put("key", 0);
list.add(one);
}
for(Map<String,Object> one : list) {
System.out.println("old key:"+one.get("key"));
}
list.stream().filter(bean -> {
if(Integer.parseInt(bean.get("key").toString())==0) {// 将value为0全部替换为true
bean.put("key", true);
}
return true;
}).collect(Collectors.toList());
Iterator<Map<String,Object>> it = list.iterator();
while(it.hasNext()) {
Map<String,Object> map = it.next();
System.out.println("filter key:"+map.get("key"));
}
}
}
标签:imp Collector image stl 图片 for int ima lis
原文地址:https://www.cnblogs.com/sung1024/p/11037467.html