Convert a double array to Double ArrayList

前端 未结 5 1851
逝去的感伤
逝去的感伤 2020-12-06 00:25

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

Exception in thread \"main\" java.lang.ClassCastException: [D ca

5条回答
  •  情书的邮戳
    2020-12-06 01:13

    Credit to bestsss for the comment which should be the answer:

    ArrayList firstValueList = new ArrayList();
    for(double d : firstValueArray) firstValueList.add(d);
    

提交回复
热议问题