我尝试将 Double[] 的 Hashmap 值分配给 List,但它抛出错误:
"The method add(Double) in the type List is not applicable for the arguments (Double[])"
ArrayList<HashMap<String, Double[]>> arl = (ArrayList<HashMap<String, Double[]>>) pd.getArrayList();
List<Double> empid = new ArrayList<Double>();
Iterator itr = arl.iterator();
while (itr.hasNext()) {
HashMap<String, Double[]> map = (HashMap<String, Double[]>) itr.next();
empid.add(map.get("id")));
}
如何将 Double[]
转换为 Double.Request
?
最佳答案
如果转换为List<Double>
这是你唯一的选择,试试这个:
ArrayList<HashMap<String, Double[]>> arl = (ArrayList<HashMap<String, Double[]>>) pd.getArrayList();
List<Double> empid = new ArrayList<Double>();
Iterator itr = arl.iterator();
while (itr.hasNext()) {
HashMap<String, Double[]> map = (HashMap<String, Double[]>) itr.next();
for (Double d : map.get("id") {
empid.add(d);
}
}
关于java - 如何将 ArrayList hashmap<String,Double[]> 分配给列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10993463/