I\'m new to these generic types. In the below code, I created a method that accepts a List of items that extends \"String\".
My Question? - When the list can be assigned
Because it's not the runtime type that's relevant here. list is still of type List extends String>, you've just happened to assign it to a new ArrayList. Consider this:
list = rand() ? new ArrayList() : new ArrayList();
The compiler could not possibly tell if list.add("test") will be valid -- it only makes decisions based on the compile-time type of list.
Note that in reality nothing extends String, it's a final class.