helt helt - 1 month ago 8
Java Question

How to convert a Double[] to double...?

Given a method definition:

public void create(double... values);


This method is called like this:

List<Double> values = ...;
Double[] doubles = values.toArray(new Double[0]);
create(doubles); // wont work


Why does it not work?

Answer
double[] unboxed = Stream.of(boxed).mapToDouble(Double::doubleValue).toArray();