Any way to stream a map like “(k,v)” instead of working with (entry)?

后端 未结 4 1873
北恋
北恋 2020-12-31 04:26

Basically I look for a way to avoid working with

entry -> entry.getValue

and

entry -> entry.getKey

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 05:02

    No, there's no way to do this; Stream only works with a single element type. There's no way around the getKey and getValue approach.

    (Streaming over the keys and calling get doesn't actually seem to be any better from your perspective, and it's likely to be strictly less efficient.)

提交回复
热议问题