i want to add element extending Type to ArrayList.
ArrayList<? extends Type>
i defined a method as below
public <T extends Type> void addItem(T itemToAdd, Class<?> classType) {
ArrayList<? extends Type> allItems = getAllItems(classType);
allItems.add(itemToAdd);
}
T itemToAdd is error. because i can't add someother type. i thought but i don't know to mention it and its error!
How to add the item via a method call?
SomeTypeandTypein your question?