I have to convert a list List<String> into a map Map<String, Float>.
The keys of the map must be strings from the list, and every value must be 0 (zero) for all keys.
How can I convert this?
I've tried:
List<String> list = List.of("banana", "apple", "tree", "car");
Map<String, Float> map = list.stream()
.distinct()
.collect(Collectors.toMap(String::toString, 0f));