Skip to main content

jdk8 Stream toArray

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-11-08

The current Stream class has toArray() only returning an Object[]. This is very unhandy if you're working with parameterized streams. In an example I was working with a Stream of CompletableFuture

, which at the end I wanted to convert into a CompletableFuture[] array with toArray() so I could check if all Futures were done with CompletableFuture.allOf. Could toArray() be made to respect types?