Here in my program it only takes 1 array that is the a but the b does not take it: c
Your error is that, within for
, you are saving the position i
of arrayA
and arrayB
in the same position i
of arrayC
. One way to do it would be like this:
public static void main(String args[])
{
int arrayA[] = {1,2,3,4,5};
int arrayB[] = {6,7,8,9,10};
int arrayC[] = new int[10];
for(int i = 0; i < 5; i++){
arrayC[i] = arrayA[i];
arrayC[i+5] = arrayB[i];
}
for(int i = 0; i < arrayC.length; i++){
System.out.println(arrayC[i]);
}
}