java - Incompatible types error while trying to create a map of maps -
i trying create map of maps using concurrentskiplistmap
. if create simple map example seems fine:
map<integer, integer> mmap2 = new concurrentskiplistmap<integer, integer>();
once try create map of maps, incompatible types
error:
map<integer, map<integer, integer>> mmap = new concurrentskiplistmap<integer, concurrentskiplistmap<integer, integer>>();
if switch definition include concurrentskiplistmap
, compiles no problems:
map<integer, concurrentskiplistmap<integer, integer>> mmap = new concurrentskiplistmap<integer, concurrentskiplistmap<integer, integer>>();
why cant define map of map's using map
interface?
i can answer question example.
map<integer, map<integer, integer> mmap = new concurrentskiplistmap<integer, concurrentskiplistmap<integer, integer>>(); mmap.put(5, new hashmap<integer, integer>());
in case, expect put line allowed? if not allowed breaks definition of mmap. if allowed breaks right hand side.
you've produced line code whether works or not gives contradiction. therefore don't allow such definitions of mmap.
Comments
Post a Comment