Saturday, July 28, 2018

JDK 11: New Default Collection Method toArray(IntFunction) [Snippet]

The "JDK 11 Early-Access Release Notes" indicate that Early Access Build 20 of JDK 11 includes a new default method on the Collection interface that "allows the collection's elements to be transferred to a newly created array of the desired runtime type." This new default methodCollection.toArray(IntFunction), works similarly to the same-named method already available on the Stream interface, Stream.toArray(IntFunction).

The next code listing demonstrates a new JDK 11 default Collection method in action (on a Set in this case).



from DZone.com Feed https://ift.tt/2Ai0pta

No comments:

Post a Comment