Java How To -Merge Two Arrays
How To Merge Two Arrays
Combine twoint 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
