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.

3
  • 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. Commented Apr 30, 2023 at 18:50
  • @HovercraftFullOfEels, have a look at the accept answer: stackoverflow.com/a/4837580/664577. It does cover streams as well (although I like the OP's title better). Commented Apr 30, 2023 at 22:07
  • Another Java 8+ duplicate: stackoverflow.com/q/46160126/664577 Commented Apr 30, 2023 at 22:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.