Java 8 extract Map values into array with stream and filter
Could anyone help me get an array of map values with stream and filtering?
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));
}
}
The result I'm looking for is ArrayList<TheMap>
with just these two entries:
TheMap("jane", "engineer")
TheMap("john", "engineer")
Basically, get TheMap
named none-null
and title
.
+3
source to share