I want to convert a Double
list to double array, and tried 2 ways (line 2 and 3), but line 3 can not pass compilation and reports an error:
Non-static method can not referenced from a static context
by IDEA tips.
when compiled by maven it report:
Incompatible type: invalid method reference.
List<Double> res = new ArrayList<>();
double[] doubles = res.stream().mapToDouble(Double::doubleValue).toArray();
Arrays.stream(res.toArray()).mapToDouble(Double::doubleValue).toArray();