Sorry if it's a silly question, but I have searched a long time and couldn't understand why the code below throws me a compilation error:
I have a first class named MenuElement which is parent to a few subclasses. It has 2 methods:
class MenuElement {
public int getType() {};
public long getId() {};
...
}
In another class, I have declared as attribute:
private LinkedHashMap<Integer, LinkedHashMap <Long, ? extends MenuElement>> mMenuElement;
And in one of the method, I have this, but the compiler cannot accept menuElement as a chidren of MenuElement:
public void onMenuElementActivationChanged(MenuElement menuElement) {
...
mMenuElement.get(menuElement.getType()).put(menuElement.getId(), menuElement);
...
}
I feel like I'm maybe missing something with java's generics logic. Someone can help please? Thanks! :)