+
+ System.out.println("Map content of exactly duplicated word inferior to the word \"milieu\":");
+ Map<String, Integer> m1 = tm.entrySet().stream()
+ .filter(map -> map.getKey().compareTo("milieu") < 0 && map.getValue() == 2)
+ .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
+ for (String wordCursor : m1.keySet()) {
+ System.out.println("Word \"" + wordCursor + "\" occured " + m1.get(wordCursor) + " times");
+ }
+
+ System.out.println("Map content of duplicates with occurence between 2 and 5:");
+ Map<String, Integer> m2 = tm.entrySet().stream()
+ .filter(map -> map.getValue() >= 2 && map.getValue() <= 5)
+ .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
+ for (String wordCursor : m2.keySet()) {
+ System.out.println("Word \"" + wordCursor + "\" occured " + m2.get(wordCursor) + " times");
+ }