Processing to make 2 array in one

int[] a = { 1, 2, 25 };
int[] b = { 9, 18 };
int[] c = new int [a.length + b.length];

Is OK you now have three arrays
a has 3 elements,
b has 2 elements and
c has 5 elements

If we look inside them we have

                  Array
Index        a      b      c
 0           1      9      0
 1           2     18      0
 2          25      X      0
 3           X      X      0
 4           X      X      0

Note X means there is no such array element
Afterwards you want hem to look like this

                  Array
Index        a      b      c
 0           1      9      1
 1           2     18      2
 2          25      X     25
 3           X      X      9
 4           X      X     18

To populate the c array you need two loops one to copy the a array into elements 0-2 and a second to copy the b array into elements 3-4

2 Likes