Convert list of Float objects to an array of float primitives in Java

98 views Asked by At

Given a List of Float objects:

List< Float > floatObjects = List.of( 7F , 42F , 99F ) ;  // Auto-boxing produces a `List< Float >`. 

… how does one easily get an array of double primitive values?

float[] floatPrimitives = floatObjects … ??? ;

I thought of making a Stream from our List of Float objects, converted to a FloatStream. But strangely, there is no FloatStream class. We have IntStream, LongStream, and DoubleStream, but no FloatStream.

0

There are 0 answers