在以下情况下我遇到问题,请参阅下面的内联评论:
public void exampleMethod() {
//Intuitively I would expect this to mean that test is set containing objects
//that subclass AbstractGroup
Set extends AbstractGroup> test;
//Yet the compiler complains here and I do not understand why?
test.add(new AnyAbstractGroupSubGroup());
//I would guess that a method call such as this at runtime
test = new HashSet()
//would mean that only objects of subgroupA can be added to the collection, but then
//what is the point in using the wildcard in the first place?
}