diff --git a/core-java-collections/pom.xml b/core-java-collections/pom.xml index d0c3c25beb..06b79fff22 100644 --- a/core-java-collections/pom.xml +++ b/core-java-collections/pom.xml @@ -68,6 +68,11 @@ commons-exec 1.3 + + one.util + streamex + 0.6.5 + diff --git a/core-java-collections/src/main/java/com/baeldung/map/java_8/MergeMaps.java b/core-java-collections/src/main/java/com/baeldung/map/java_8/MergeMaps.java index a5dada4152..e62e95b634 100644 --- a/core-java-collections/src/main/java/com/baeldung/map/java_8/MergeMaps.java +++ b/core-java-collections/src/main/java/com/baeldung/map/java_8/MergeMaps.java @@ -1,8 +1,13 @@ package com.baeldung.map.java_8; import com.baeldung.sort.Employee; +import one.util.streamex.EntryStream; +import one.util.streamex.IntCollector; +import one.util.streamex.StreamEx; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +25,18 @@ public class MergeMaps { //streamConcat(); - streamOf(); + //streamOf(); + + streamEx(); + } + + private static void streamEx() { + Map map3 = EntryStream.of(map1) + .append(EntryStream.of(map2)) + .toMap((e1, e2) -> e1); + + System.out.println(map3); + } private static void streamOf() {