How can I convert Map
to Map
?
This does not work:
Map map = ne
Great solutions here, just one more option that taking into consideration handling of null
values:
Map map = new HashMap<>();
Map stringifiedMap = map.entrySet().stream()
.filter(m -> m.getKey() != null && m.getValue() !=null)
.collect(Collectors.toMap(Map.Entry::getKey, e -> (String)e.getValue()));