Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

creating a set of first values from a map having pair values

I have a map which has pair values

 Map<String, Pair<Request, Request>> myRequest;

I would like to create a set only fetching the first value from the pair. Is there way to use Java streams to do this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Not sure what the definition of Pair is but something like

myRequest.values()
    .stream()
    .map(it -> it.getFirst())
    .collect(Collectors.toSet())
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading