将双数组转换为双数组列表 [英] Convert a double array to Double ArrayList
本文介绍了将双数组转换为双数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试将双数组转换为双数组列表时,出现以下错误:
When I try to convert a double array to a Double arrayList I got the following error:
线程main"中的异常 java.lang.ClassCastException: [D 不能转换为 java.lang.Double
Exception in thread "main" java.lang.ClassCastException: [D cannot be cast to java.lang.Double
下面是我的代码.
double [] firstValueArray ;
ArrayList
我正在将此列表与另一个列表进行比较,并将结果分配给另一个双变量.
I am comparing this list with another list and assign the result to another double variable.
请告诉我这个错误的原因.
Please let me know the reason for this error.
推荐答案
唉,Arrays.asList(..)
不适用于原语.Apache commons-lang 有
Alas, Arrays.asList(..)
doesn't work with primitives. Apache commons-lang has
Double[] doubleArray = ArrayUtils.toObject(durationValueArray);
List<Double> list = Arrays.asList(doubleArray);
这篇关于将双数组转换为双数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文