Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 5
    Why would you use this instead of Stream.toArray(IntFunction)? Commented May 31, 2018 at 12:41
  • I needed a collector to pass to the 2-arg Collectors.groupingBy so that I could map some attribute to arrays of objects per attribute value. This answer gives me exactly that. Also @DidierL. Commented Dec 9, 2018 at 13:34
  • Since Java 11 the finisher in collectingAndThen can be written as list -> list.toArray(converter) due to addition of Collection.toArray​(IntFunction) Commented Nov 22, 2020 at 9:45