Creating a generic array in Java

Generic array initialization

Recently I work with CompletableFutures. I used the allOf method which
takes a varargs as input. Based on the request, a couple of things had to be processed.

So how do I create a generic array that I could use at CompletableFuture.allof()?
Array.newInstance together with toArray() does the trick.

This is my solution: