- I guess that’s called array zipping or something like that.
- All values in array a[] will go into c[]'s even indices.
- All values in array b[] will go into c[]'s odd indices.
- You can make 1 loop to iterate over c[] by 2 increment steps:
for (int i < 0; i < c.length; i += 2) { - Take advantage that in Java when we divide 2 int values, we get it truncated to an integer too:
c[i] = a[i / 2];
c[i + 1] = b[i / 2];
3 Likes