Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaCollectors toMap groupingBySingle-choice MCQ

What does toMap do when one of the values is null, as in the snippet?

import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) { Map<String, String> m = Stream.of("x") .collect(Collectors.toMap(s -> s, s -> (String) null)); System.out.println(m); } }