Processing to make 2 array in one

Here is the questions in English thanks to google translate

Merge arrays

There are two arrays a and b. Create a new array c that is as long as a and b taken together and also contains the values ​​of a and b (in that order).

int a = {1, 2, 25}; int b = {9, 18}; // write code here println ©;

You should see this on the console here:

[0] 1 [1] 2 [2] 25 [3] 9 [4] 18

Do not use the concat () or splice () processing functions. Your code should also work if you add or remove elements from a and / or b.

tip

Break the problem down into two steps. In step 1, fill the first part of c with the values ​​of a. In step 2, fill the second part of c with the values ​​of b.

You solve each step with your own for loop. Step 1 is easy because the index numbers of a and c are equal (c [0] gets value of a [0] etc.). Step 2 requires a little change. What is the index number in c for the first value of b?

2 Likes