Not valid, as if it were valid, you could add non-integer lists to ml .
Example (invalid):
Map<String, List<Integer>> ml; Map<String, List<?>> ml3 = ml; ml3.put("strings", Arrays.asList("evil","string")); List<Integer> l = ml.get("strings");
Why Map<String, ?> ml2 = ml; acting? This is because using a wildcard tells the compiler to prevent new elements from being added, i.e. ml2.put("strings", Arrays.asList("evil","string")); will not be allowed (the compiler does not perform type checking, it just sees a wildcard and knows that you should not call this method.
source share