Home > Blockchain >  creating a set of first values from a map having pair values
creating a set of first values from a map having pair values

Time:07-22

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?

CodePudding user response:

Not sure what the definition of Pair is but something like

myRequest.values()
    .stream()
    .map(it -> it.getFirst())
    .collect(Collectors.toSet())
  • Related