顶部地图有3个子地图,每个子地图有不同的对象。
如下面的代码,如何将通用添加到地图顶部?
Map<String,Map> top = new ConcurrentHashMap<String, Map>();
Map<String,TypeA> subA = new ConcurrentHashMap<String,TypeA>();
Map<Long,TypeB> subB = new ConcurrentHashMap<String,TypeB>();
Map<String, long[]> sbuC = new ConcurrentHashMap<String,TypeC>();
top.put("SUB_A", subA);
top.put("SUB_B", subB);
top.put("SUB_C", subC);
答案 0 :(得分:2)
试试这个:
Map<String,Map<<? extends Object,?>> top = new ConcurrentHashMap<String, Map< <? extends Object,?>>();
键是object
,值是任何类型。