Concatenate two arrays java
//USing Apache Commons Lang library.
int[] both = ArrayUtils.addAll(first, second);
Concatenate two arrays java
//USing Apache Commons Lang library.
int[] both = ArrayUtils.addAll(first, second);
java add two arrays together
Object[] arrThree = new Object[arrTwo.length + arrOne.length];
int index = arrTwo.length;
for (int i = 0; i < arrTwo.length; i++) {
arrThree[i] = arrTwo[i];
}
for (int i = 0; i < arrOne.length; i++) {
arrThree[i + index] = arrOne[i];
}
how to merge two arrays in java
public static void main(String[] args) {
int[] x = {1, 2, 3};
int[] y = {4, 5, 6};
int[] merge = new int[x.length + y.length];
for (int i = 0; i < x.length; i++) {
merge[i] += x[i];
}
for (int i = 0; i < y.length; i++) {
merge[x.length + i] += y[i];
}
System.out.println(Arrays.toString(merge));
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us