Using Java 8 I am trying to concatenate two float arrays:
void f(float[] first, float[] second) {
float[] both = ???
}
From a quick SO search, I thought I could simply follow instruction from here. So I tried:
float both[] = FloatStream.concat(Arrays.stream(first), Arrays.stream(second)).toArray();
But this does not compile as explained here. So I tried the less efficient solution and use a Stream
directly:
float[] both = Stream.concat(Arrays.stream(first), Arrays.stream(second)).toArray(float[]::new);
It fails to 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 simple) way of concatenating two float[]
arrays in Java 8 ?
Update: obviously the whole point of the question is that I have to deal with float
and not double
.