wanted to know how to put 2 fixes in 1 [duplicate] array

0

Here in my program it only takes 1 array that is the a but the b does not take it: c

    
asked by Yoxan Gonzalez 24.05.2017 в 01:42
source

1 answer

2

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]);
    }
}
    
answered by 24.05.2017 в 12:54