I want to define the following class as such:
public class CollectionAttribute<E extends Collection<T>> { private String name; private E value; public CollectionAttribute(String name, E value) { this.name = name; this.value = value; } public E getValue() { return value; } public void addValue(T value) { value.add(T); } }
This will not compile ( cannot resolve symbol T ). If I replaced the class declaration as follows:
public class CollectionAttribute<E extends Collection<?>>
Then I can not refer to the parameterized type of the collection.
Am I missing something or have reached the generic limit in Java?
java generics
Two shoes
source share