title: CompletableFuture chaining results
body: <p>I am trying to chain the calls/results of the methods to the next call. I get compile time error methodE because if am not able to get the reference of objB from the previous call. </p>
  
  <p>How can I pass the result of the previous call to the next chain? Have I completely misunderstood the process? </p>
  
  <pre><code>Object objC = CompletableFuture.supplyAsync(() -&gt; service.methodA(obj, width, height))
      .thenApply(objA -&gt; {
      try {
          return service.methodB(objA);
      } catch (Exception e) {
          throw new CompletionException(e);
      }
  })
     .thenApply(objA -&gt; service.methodC(objA))
     .thenApply(objA -&gt; {
     try {
         return service.methodD(objA); // this returns new objB how do I get it and pass to next chaining call 
         } catch (Exception e) {
             throw new CompletionException(e);
         }
      })
      .thenApply((objA, objB) -&gt; {
         return service.methodE(objA, objB); // compilation error 
    })
   .get();
  </code></pre>