diff --git a/core-java-modules/core-java-collections-set-2/pom.xml b/core-java-modules/core-java-collections-set-2/pom.xml
index 680c01d8ca..d1a108f8bb 100644
--- a/core-java-modules/core-java-collections-set-2/pom.xml
+++ b/core-java-modules/core-java-collections-set-2/pom.xml
@@ -20,6 +20,17 @@
${junit-platform.version}
test
+
+ org.testng
+ testng
+ 7.7.0
+ test
+
+
+ com.google.guava
+ guava
+ 32.1.1-jre
+
diff --git a/core-java-modules/core-java-collections-set-2/src/main/java/com/baeldung/cartesianproduct/CartesianProduct.java b/core-java-modules/core-java-collections-set-2/src/main/java/com/baeldung/cartesianproduct/CartesianProduct.java
new file mode 100644
index 0000000000..d4725d74f1
--- /dev/null
+++ b/core-java-modules/core-java-collections-set-2/src/main/java/com/baeldung/cartesianproduct/CartesianProduct.java
@@ -0,0 +1,75 @@
+package com.baeldung.cartesianproduct;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import com.google.common.collect.Sets;
+
+public class CartesianProduct {
+ public List> getCartesianProductIterative(List> sets) {
+ List> result = new ArrayList<>();
+ if(sets == null || sets.isEmpty()) {
+ return result;
+ }
+ int totalSets = sets.size();
+ int totalCombinations = 1 << totalSets;
+ for(int i = 0; i < totalCombinations; i++) {
+ List