Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java How To - Merge Two Arrays?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___[] a = {1, 2, 3};How To Merge Two Arrays
Combine two int arrays into a single array:
Example
int[] a = {1, 2, 3};
int[] b = {4, 5};
int[] merged = new int[a.length + b.length];
int idx = 0;
for (int n : a) merged[idx++] = n;
for (int n : b) merged[idx++] = n;
for (int n : merged) {
System.out.print(n + " ");
}
// Output: 1 2 3 4 5