double[]
is converted to a List<Float>
, I thought Streams map operation could convert a double stream to a float stream, but no... it is still double stream. In the following 2 conversions, the first works, as v.floatValue() becomes float type, but (float) v still is double type. Why?
List<Float> collect = Arrays.stream(vec).boxed().map(v -> v.floatValue()).collect(Collectors.toList());
(float)v is still double. Required List<Float>, provided List<Double>
List<Float> collect2 = Arrays.stream(vec).map(v -> (float) v).boxed().collect(Collectors.toList());