Using Java 8 I am trying to combine two floating point arrays:
void f(float[] first, float[] second) {
float[] both = ???
}
From a quick SO search, I thought I could just follow the instructions here . So I tried:
float both[] = FloatStream.concat(Arrays.stream(first), Arrays.stream(second)).toArray();
But this does not compile as described here . So I tried a less efficient solution and directly used Stream
:
float[] both = Stream.concat(Arrays.stream(first), Arrays.stream(second)).toArray(float[]::new);
It does not compile from my eclipse, saying:
The method stream(T[]) in the type Arrays is not applicable for the arguments (float[])
What is the most efficient (and easiest) way to concatenate two arrays float[]
in Java 8?
Update: Obviously, the whole point of the question is what I have to deal with float
, not double
.
source
share