Switch the array places in a loop

Unfortunately. I could not find the solution.
Could you please give me a further hint.

I tried it like this

int[] a = {1, 2, 3, 4};
int[] b = {10, 20, 30, 40};

int[]c = new int[a.length + b.length];

for(int i =0; i<a.length; i+=2)
{
  c[i] = a[i/2];
  for(int j=0; j <c.length; j+=2)
  {
    c[j+1] = b[j/2];
  }
}

println(c);

The 4. array place and the 6. place are 0.

1 Like