KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Given this example from the generics tutorial . List<String> list = new ArrayList<>(); list.add("A"); // The following statement should fail since addAll expects // Collection<? extends String> list.addAll(new ArrayList<>()); Why does the last line not compile, when it seems it should compile. The first line uses a very similar construct and compiles without a problem. Please explain elaborately.
Tags (comma-separated)
Save Edits
Cancel