java - 如何将 ArrayList hashmap<String,Double[]> 分配给列表

标签 java

我尝试将 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/

相关文章:

java - Jsoup登录穆迪

java - Jython jmxmp 协议(protocol)支持

java - 停止缩放 JPanel 的背景图像

java - 在 Java 中从 URL 解析 XML 时出现 MalformedByteSequenceException

java - 方法声明中的句点意味着什么?

java - 代码实现相同的两种方法

java - 如何正确清理错误初始化的对象?

java - 删除 View 会在线性布局中留下空白空间

java - 数组列表和链表的区别

java - 方法 renderJSON(Map<String,String>) 未定义