List<? extends Object> List<? extends Object> can be used with each type of list.
Do you think it would be safe to allow it to add any objects if, for example,
List<? extends Object> a1 = new ArrayList<Integer>(); a1.add("string");
Only the safe value to add will be null , since it does not belong to any particular type.
To get rid of this problem, you can use, for example, List<String> a1 = new ArrayList<String>() or List a1 = new ArrayList()
source share