转换一个双阵列双的ArrayList [英] Convert a double array to Double ArrayList

查看:95
本文介绍了转换一个双阵列双的ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试了双数组转换为Double ArrayList中我得到了以下错误:

When I try to convert a double array to a Double arrayList I got the following error:

异常线程mainjava.lang.ClassCastException:[D不能被转换为java.lang.Double中的

Exception in thread "main" java.lang.ClassCastException: [D cannot be cast to java.lang.Double

下面是我的code。

double [] firstValueArray ;

的ArrayList<双> firstValueList =新的ArrayList(Arrays.asList(firstValueArray));

我与另一个列表相比较,这个名单和结果分配给另一个双变量。

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(..)不与原语工作。阿帕奇公地郎

Alas, Arrays.asList(..) doesn't work with primitives. Apache commons-lang has

Double[] doubleArray = ArrayUtils.toObject(durationValueArray);
List<Double> list = Arrays.asList(doubleArray);

这篇关于转换一个双阵列双的ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆