title: How can I make Cartesian product with Java 8 streams?
body: <p>I have the following collection type:</p>
  
  <pre><code>Map&lt;String, Collection&lt;String&gt;&gt; map;
  </code></pre>
  
  <p>I would like to create unique combinations of each of <code>map.size()</code> from a single value in the collection for each Key.</p>
  
  <p>For example suppose the map looks like the following:</p>
  
  <pre><code>A, {a1, a2, a3, ..., an}
  B, {b1, b2, b3, ..., bn}
  C, {c1, c2, c3, ..., cn}
  </code></pre>
  
  <p>The result I would like to get would a <code>List&lt;Set&lt;String&gt;&gt;</code> result, looking similar to (ordering is not important, it just needs to be a 'complete' result consisting of all possible combinations):</p>
  
  <pre><code>{a1, b1, c1},
  {a1, b1, c2},
  {a1, b1, c3},
  {a1, b2, c1},
  {a1, b2, c2},
  {a1, b2, c3},
  ...
  {a2, b1, c1},
  {a2, b1, c2},
  ...
  {a3, b1, c1},
  {a3, b1, c2},
  ...
  {an, bn, cn}
  </code></pre>
  
  <p>This is basically a counting problem, but I would like to see if a solution is possible using Java 8 streams.</p>