Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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));
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #merge #arrays #java
ADD COMMENT
Topic
Name
6+5 =