I have a FourByFourBoard class that extends GameBoard . I define the following fields:
private Map<Integer,List<Key<? extends GameBoard>>> mGameTypeToKeysMap = new Hashtable<Integer,List<Key<? extends GameBoard>>>(); private List<Key<FourByFourBoard>> mFourByFourBoardKeys = new ArrayList<Key<FourByFourBoard>>();
In my constructor, I am trying to call:
mGameTypeToKeysMap.put(Game.FOUR_BY_FOUR, mFourByFourBoardKeys);
But I get this:
The put(Integer, List<Key<? extends GameBoard>>) method put(Integer, List<Key<? extends GameBoard>>) of type Map<Integer,List<Key<? extends GameBoard>>> Map<Integer,List<Key<? extends GameBoard>>> not applicable for Arguments (int, List<Key<FourByFourBoard>>)
I can use a different approach to do what I'm trying to do, but with a little stare at the code, I cannot understand why this is not working.
EDIT
This problem may be simpler than I thought:
If I try:
Key<GameBoard> a = mFourByFourBoardKeys.get(0);
I get:
Type mismatch: cannot convert from Key<FourByFourBoard> to Key<GameBoard>
Even:
GameBoard someBoard = new FourByFourBoard();
It is legal. So this is still a general question, but the compilation was not important. And my head is still spinning a bit.
source share