Arnaud Denoyelle Arnaud Denoyelle - 2 years ago 160
Java Question

How to get a Stream from a float[]

I was learning how to use java 8 streams when I noticed something weird.
has methods for everything but float arrays :

  •[]) : IntStream

  •[]) : LongStream

  •[]) : DoubleStream

Similarly, there are Stream implementations for int, double etc but not floats :

  • IntStream

  • LongStream

  • DoubleStream

Is there a reason for that?

what is the recommended way to work with float streams?

Answer Source

from Java SE 8 for the Really Impatient by Cay S. Horstmann :

2.12. Primitive Type Streams

... If you want to store short, char, byte, and boolean, use an IntStream, and for float, use a DoubleStream. The library designers didn’t think it was worth adding another five stream types.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download