Concatenating two int[]

You can simply concatenate primitive(int) streams using IntStream.concat as:

int[] m = IntStream.concat(IntStream.of(c), IntStream.of(d)).toArray();

You can use IntStream.concat in concert with Arrays.stream to get this thing done without any auto-boxing or unboxing. Here's how it looks.

int[] result = IntStream.concat(Arrays.stream(c), Arrays.stream(d)).toArray();

Note that Arrays.stream(c) returns an IntStream, which is then concatenated with the other IntStream before collected into an array.

Here's the output.

[1, 34, 3, 1, 5]


Use for loops, to avoid using toArray().

int[] e = new int[c.length+d.length];
int eIndex = 0;
for (int index = 0; index < c.length; index++){
    e[eIndex] = c[index];
    eIndex++;
}
for (int index = 0; index < d.length; index++){
    e[eIndex] = d[index];
    eIndex++;
}