Groovy 2.5.0 adds several methods to make working with Java 8 Streams more groovy. First, the methods toList and toSet are added to the Stream class. These methods will convert the stream to a List and Set , using the Stream.collect method with Collectors.toList and Collectors.toSet as the argument. Furthermore, we can convert any array object to a Stream using the stream method that is added to all array objects.

In the following example, we use the support of converting an array to a Stream and then getting a List and Set from the stream:

Source de l’article sur DZONE

L’assistance proposée par ANKAA PMO

ANKAA PMO présent depuis plus de 20 ans sur le marché des services IT, accompagne les DSI dans leur recherche de compétences pour des besoins de renforts en mode régie ou l’externalisation de projets.
Vous souhaitez plus d’information ? Cliquez ici


0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *