有人可以帮助我通过数据流和过滤获取地图值的数组吗?Java 8将地图的值检索到流和过滤器的数组
public class TheMap extends HashMap<String, String> {
public TheMap(String name, String title) {
super.put("name", name);
super.put("title", title);
}
public static void main(final String[] args) {
Map<Long, Map<String, String>>map = new HashMap<>();
map.put(0L, null);
map.put(1L, new TheMap("jane", "engineer"));
map.put(2L, new TheMap("john", "engineer"));
map.put(3L, new TheMap(null, "manager"));
map.put(4L, new TheMap("who", null));
map.put(5L, new TheMap(null, null));
}
}
,我寻找的结果是ArrayList<TheMap>
只有这两个条目:
TheMap("jane", "engineer")
TheMap("john", "engineer")
基本上,检索TheMap
与none-null
名称和title
。
这是奇怪的,你把一个覆盖地图到另一个地图?你确定你要这么做吗?你不想要一个只有名称和标题属性的bean吗? –