Given this code segment:
List<Map<List<Integer>, List<String>>> list = new ArrayList<>(); // ADD_MAP Map<List<Integer>, List<String>> map = new HashMap<>(); list.add(null); // ADD_NULL list.add(map); list.add(new HashMap<List<Integer>, List<String>>()); // ADD_HASHMAP list.forEach(e -> System.out .print(e + " ")); // ITERATE
Which one of the following options is correct?
e)
the lines marked with comments ADD_MAP and ADD_HASHMAP are valid uses of the diamond operator to infer type arguments.
Calling the add()
method passing null does not result in a NullPointerException.
the program, when run, will successfully print the output null {} {} (null output indicates a null value was added to the list, and the {} output indicates that Map is empty).