I have a List of String like:
List locations = Arrays.asList(\"US:5423\",\"US:6321\",\"CA:1326\",\"AU:5631\");
And I want to
Try this
Map> locationMap = locations.stream() .map(s -> new AbstractMap.SimpleEntry(s.split(":")[0], s.split(":")[1])) .collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.mapping(Map.Entry::getValue, Collectors.toList())));