- Make a for-loop an iterate over
Array1
andArray2
- Do
Integer.parseInt(String.valueOf(Array1[i])+String.valueOf(Array2[i]));
- Fill the
Array3
in the for-loop with the calculated valued.
That’s it.
int[] Array1 = new int[] {3,3,3};
int[] Array2 = new int[] {3,2,1};
int[] Array3 = new int[Array2.length];
for(int i = 0; i<Array1.length; i++) {
Array3[i] = Integer.parseInt(String.valueOf(Array1[i])+String.valueOf(Array2[i]));
}
Output:
Array3[] = {33,32,31}
solved How to concatenate two arrays into 1 single array using java? [duplicate]