I have this code:
String[] arr1 = {"asd1", "asd2", "asd3", "asd4", "asd5", "asd6", "asd7"};
String[] arr2 = {"asd8", "asd9", "asd10", "asd11", "asd12", "asd13", "asd14"};
String[] concatenated = Stream.of(arr1, arr2)
.flatMap(Stream::of)
.toArray(String[]::new);
String[] concatenated = Stream
.concat(Arrays.stream(arr1), Arrays.stream(arr2))
.toArray(String[]::new);
String[] concatenated = Stream.of(arr1, arr2)
.reduce(new String[arr1.length + arr2.length],
(String[] a, String[] b) -> )); ///// how to proceed from here?
System.out.println(Arrays.toString(concatenated));
I am playing around and i didn't managed to find how to use the reduce function to combine them both to get this result:
[asd1, asd2, asd3, asd4, asd5, asd6, asd7, asd8, asd9, asd10, asd11, asd12, asd13, asd14]
note: The order doesn't really matter, the important thing is to get them both into one array with the reduce function..
Is it possible to do it with the reduce?