Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaGenerics (bounds/wildcards/PECS)Single-choice MCQ

Why does the marked line fail to compile?

List<? extends Number> nums = new ArrayList<Integer>(); nums.add(Integer.valueOf(1)); // compile error