如何正确实例化HashMap其值是变体的a List<Number>- 即,值可以采用List<Long>和/或的形式List<Double>。这是我到目前为止所尝试的:
HashMap<String, List<Number>> foo = new HashMap<String, List<Number>>();
foo.put("Tenticles", new ArrayList<Long>());
错误信息:The method put(String, List<Number>) ... is not applicable for the arguments (String, List<Long>)。
我还希望能够将 a 添加Long到组成部分List<Long>,同样也可以添加 any Double。
编辑这些答案没有显示如何将 aLong或 aDouble到组成列表之一。