title: How to call completable future in a loop and combine all the results?
body: <p>I am trying to achieve something like this. This is a made up example that expresses the intent.</p>
  
  <p>I want all the completable futures to execute and combine all their results to one result and return that. So for the example below, the collection allResults should have the strings "one", "two", "three", 3 times each. I want them all to run in parallel and not serially.</p>
  
  <p>Any pointers to what API on the completable future I could use to achieve this, would be very helpful.</p>
  
  <pre><code>public class Main {
  
  
      public static void main(String[] args) {
  
          int x = 3;
          List&lt;String&gt; allResuts;
  
          for (int i = 0; i &lt; x; i++) {
  
             //call getCompletableFutureResult() and combine all the results
          }
  
      }
  
      public static CompletableFuture&lt;List&lt;String&gt;&gt; getCompletableFutureResult() {
  
          return CompletableFuture.supplyAsync(() -&gt; getResult());
      }
  
      private static List&lt;String&gt; getResult() {
  
  
          List&lt;String&gt; list = new ArrayList&lt;&gt;();
          list.add("one");
          list.add("two");
          list.add("three");
  
          return list;
      }
  
  
  }
  </code></pre>