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
Using Java 8 Streams API this is achieved with
DoubleStream.of(doublesArray).boxed().collect(Collectors.toList());
If returning an ArrayList
as an implementation is required then use
DoubleStream.of(doublesArray).boxed().collect(Collectors.toCollection(ArrayList::new));
This one-liner doesn't require any additional libraries.