Could someone suggest how could I transform list like ["bla", "blabla", "blablabla"] to map like {"bla" : 3, "blabla" : 6, "blablabla" : 9} with words stands for keys and values stands for words lengths?
I do something like:
Map<String, Integer> map = list.stream().collect(Collectors.groupingBy(Function.identity(), String::length));
but have no luck.
Thank you!
Collectors.toMap. And make sure your stream isdistinct(), otherwise you'll get an exception if you have duplicates inlist.