Java Lambda: Difference between revisions
Jump to navigation
Jump to search
Created page with "==References== {| | valign="top" | * [https://stackoverflow.com/questions/30089469/ Sum values in a Map with a stream] | valign="top" | |}" |
No edit summary |
||
| Line 1: | Line 1: | ||
<source lang="java"> | |||
Map<String, String> insured = Stream.of("Adults:1", "Children:1", "Senior Citizen:10") | |||
.map(pair -> pair.split(":")) | |||
.collect(Collectors.toMap(array -> array[0], array->array[1])); | |||
</source> | |||
==References== | ==References== | ||
{| | {| | ||
Revision as of 04:25, 6 September 2021
Map<String, String> insured = Stream.of("Adults:1", "Children:1", "Senior Citizen:10")
.map(pair -> pair.split(":"))
.collect(Collectors.toMap(array -> array[0], array->array[1]));
References
|
|