3

Arrays.stream does not accept primitive type float data. Is there a method to convert from float[] to List<Float>?

Tiina
  • 4,285
  • 7
  • 44
  • 73
  • 1
    @KarthikeyanVaithilingam It does not. The issue the OP is facing is that the JDK classes do not have `FloatStream` the OP would like it to have. – terrorrussia-keeps-killing Mar 25 '22 at 06:20
  • 1
    It might be implemented like this: `IntStream.range(0, array.length).mapToObj(i -> array[i]).collect(Collectors.toUnmodifiableList())` (as suggested by Brian Goetz https://stackoverflow.com/a/23556852/12232870 ) – terrorrussia-keeps-killing Mar 25 '22 at 06:24
  • Arrays.stream() has methods for Arrays.stream(int[]) : IntStream, Arrays.stream(long[]) : LongStream, Arrays.stream(double[]) : DoubleStream. But, Arrays.stream() did not have FloatStream. Is this useful for you- https://microeducate.tech/how-to-get-a-stream-from-a-float/ ?? – Sibin Rasiya Mar 25 '22 at 07:00

0 Answers0