Group a list of strings by length
It's not only possible but also a great example of how functional programming can make code much simpler and readable:

  public Map&lt;Integer,List&lt;String&gt;&gt; mapLengthToMatchingStrings(List&lt;String&gt; strings){
        return strings.stream().distinct().collect(Collectors.groupingBy(String::length));
    }


(The distinct part is optional, regarding whether you want duplicates in the lists)