Traverse over map with java8

hi, today we introduce the new method to traverse over the Map object with java 8.

1. construct a Map object

private static Map<String,String> constructMap() {
        return new HashMap<String,String>() {

2. Iterate over the map with stream and for-each

map.keySet().stream().forEach(k-> System.out.println(k+"-->"+map.get(k)));

You can find that java 8 stream and forEach is very easy to use and understand.

You can find more java 8 documents here: