1
我要填写一个HashMap<Integer,Double[]>
如何在添加到Map时将double数组添加到Double数组?
Map<Integer,Double[]> cached_weights = new HashMap<Integer,Double[]>();
只有定期int
和double[]
,什么是做到这一点的最好方法是什么?
我看到this question,但它回答了相反的问题。
它被称为“拳击”。 – immibis 2015-02-24 03:47:15
如果你想使用'int'类型作为键而不是'Integer',那么这是不可能的。另外'Double []'和'double []'不是协变的,'double []'不会被自动装箱到'Double []'。 – Pshemo 2015-02-24 03:47:32
另外,'Double []'不是* boxed'double []'(装箱不适用于数组),并且您可以在hashmap中存储'double []'。 – immibis 2015-02-24 03:47:45