0

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.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • 1
    @AnthonyAccioly the answers to that question were all written before Java streams came into being. Edit: Whoops. Closed before I could post the comment. I'm not sure that that is a correct duplicate, to be honest. – Hovercraft Full Of Eels Apr 30 '23 at 18:50
  • @HovercraftFullOfEels, have a look at the accept answer: https://stackoverflow.com/a/4837580/664577. It does cover streams as well (although I like the OP's title better). – Anthony Accioly Apr 30 '23 at 22:07
  • Another Java 8+ duplicate: https://stackoverflow.com/q/46160126/664577 – Anthony Accioly Apr 30 '23 at 22:13

0 Answers0