如何利用Stream类操作查询到的sql语句的List

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class StreamTestMap {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Map m1 = new HashMap();
		List> li = new ArrayList();
		List result = new ArrayList();
		m1.put("age", 12);
		m1.put("name", "张三");
		li.add(m1);
		Map m2 = new HashMap();
		m2.put("age", 13);
		m2.put("name", "李四");
		li.add(m2);
		Map m3 = new HashMap();
		m3.put("age", 14);
		m3.put("name", "王五");
		li.add(m3);
		result=li.stream().filter(age -> (Integer)age.get("age")>=13)
				.map(e -> e.get("name"))
				.collect(Collectors.toList());
		System.out.println(result);
	}
}
 
  

 

你可能感兴趣的:(java)