concatenate two arrays in java

Solutions on MaxInterview for concatenate two arrays in java by the best coders in the world

showing results for - "concatenate two arrays in java"
Moritz
28 Aug 2017
1import java.util.Arrays;
2
3public class Concat {
4
5    public static void main(String[] args) {
6        int[] array1 = {1, 2, 3};
7        int[] array2 = {4, 5, 6};
8
9        int aLen = array1.length;
10        int bLen = array2.length;
11        int[] result = new int[aLen + bLen];
12
13        System.arraycopy(array1, 0, result, 0, aLen);
14        System.arraycopy(array2, 0, result, aLen, bLen);
15
16        System.out.println(Arrays.toString(result));
17    }
18}
Mirko
06 Jan 2018
1public static void main(String[] args) {
2
3// for each ile cozumu
4        String[] arr3 = {"A", "B", "C","Z","N"};
5        String[] arr4 = {"D", "E", "F","G","U"};
6
7ArrayList<String> list1 = new ArrayList<>(); //[A, B, C, Z, N, D, E, F, G, U]
8
9        for( String each: arr3 ){
10            list1.add( each );
11        }
12        for(String each1 : arr4  ){
13            list1.add(each1);
14        }
15        System.out.println(list1); // [A, B, C, Z, N, D, E, F, G, U]
16    }
17
Jeremy
14 Nov 2017
1public static void main(String[] args) {
2
3// for each ile cozumu
4        String[] arr3 = {"A", "B", "C","Z","N"};
5        String[] arr4 = {"D", "E", "F","G","U"};
6
7ArrayList<String> list1 = new ArrayList<>(); 
8  //[A, B, C, Z, N, D, E, F, G, U]
9
10        for( String each: arr3 ){
11            list1.add( each );
12        }
13        for(String each1 : arr4  ){
14            list1.add(each1);
15        }
16        System.out.println(list1); // [A, B, C, Z, N, D, E, F, G, U]
17    }
queries leading to this page
merge to arrays javahow to merge to arrays in javaconcatinating arrays javaconcatenate array javacombine 2 arrays in javaconcat 2 array javahow to merge arrays javamerging 2 arrays in javaarray merge in javahow to merge two array in javaconcatenarte two array in javahow to concatenate two arrays in javajava concatenate 2 arraysmerge two arra in javahow to merge an array in javamerging of two arrays in javacombining two arrays in javajava concat arrays stringcombine 2 arrays javacancatenate array javacombining arrays javahow to join two integer arrays in javajava concat arrayshow to concat array in javawrite a program to merge two arrays in third array in javahow to merge to array in javamerge array javacombine two arrays javajava concat arrayconcat two array in javaadd two arrays in one array in javaadd two array in javacombine two array javacombine two array in javaconcatenate four array javajava how to combine arraysmerge 2 int array in javamerge two different arrays in javaconcat arrays javahow to add two arrays in javawap to merge two arrays in javamerging array in javahow to concat two arrays javamerge two arrays in javacan you merge two arrays in javajava merge 2 arrayshow to fuze 2 arrays together javamarge array in javajava concatenate arraysmerging arrays javajoin two arrays in javajava array concatenationconcatenate 2 string arrays in javahow to put two arrays together javaadding 2 arrays in javaarray concatenation javajava append two arrayshow to concatenate integer array elements in javaconcatination of two arrays in javahow to concatenate to array javajava concate arraysmerge 2 arrays javahow to concatinate two array in javamerging two array in javaconcatenate two array javaadd two arrays in javajava combine arrayshow to concatenate an array javahow to join two arrays in javahow to combine arrays in javajava merge arraysappend two arrays in javaconcat to arrays ajavahow to merge arrays in javajava program to merge two arraysconcat to arrays javamerge two array in javajava merge contents of arrays togetherconcat multiple array in javamerge 2 string arrays javamerge two integer arrays in javamerge two int arrays javahow to concat two arrays in javahow to combine two integer arrays in javahow to concatenate the array of arrays in javajava array concatmerge array program in javaconcat two arrays javacombine to arrays javamerge elements and a array javaconcat elements of array javaadd 2 arrays javahow to concat 2 array in javahow to merge arrays in javahow to combine two arrays javajava code to merge two arrayshow to merge two string arrays in javaprogram to merge two arrays in javaconcat two arrays in javacombine two arrays javasjava merge arraymerge function in java for arraysjava array concatenation methodinserting two arrays in javahow to concatenate an array in javamerge 2 arrays in javajava join two arrays togetherhow to combine two arrays javashow to concat two string arrays in javahow to merge two arrays in javaarray concat two arrays in javaconcatenate two arrays in javaconcatenation of arraya javaconcat 2 arrays javaconcatenate integer array javaconcate an array in javamerge array in javaconcatenation of two arrays in javahow to append two arrays in javamerge 3 arrays in place javamerge arrays javaeasiest way to merge arrays javahow to merge 2 arrays in javahow to merge two arrays with using third array in javaconcatenate two string arrays javahow to merge 2 arrys in javamerging arrays in javamerging two arrays in java functionmerge to array in javajava concat 2 arraysconcatenate two arrays javajava program to concatenate 2 arraysmerging an array in javahow to concatenate array elements in javajava merge 7e2 arrayscombine two arrays in javaconcatenate arrays javahow to join 2 arrays javajoin two arrays javahow to merge two arrays javahow merge 2 arrays javajava join 2 arraysconcatenating two arrays in javamerging of arrays in javajava how to merge two arrayshow to conccat to two arrays in javawrite a program to merge two arrays in javaconcat array javajava combine 2 arrayshow to combine 2 arrays in javahwo to join two arrays in javatwo arrays in one javaadding two arrays javahow to merge two arrays in third array in javaconcat array javajoin 2 arrays javajava combine two arraysmerging two arrays in javajava merge arrays togetherhow to merge two arrays in java 3fadd two arrays javahow to combine two arrays in javahow to combine arrays javaconcat array in javacombine arrays javamerge arrays in javamerge multiple arrays java array merge java concatinating two arrays in javahow to merge array in java concatenate two arrays in javamerge two array javahow to combine two arrays in one javahow to add 2 arrays javaarrays combineren javaadd 2 arrays in javahow to combine all arrays into one javajava how to combine arrayhow to merge arrays into one new array javamerger 2 array in javajoin two int array javajoin two array javahow to merge two arrays inn javahow to merge three arrays in javajava merge two arrayshow to add two array in javahow to join two arrays into one in javaarray concat javamerge two arrays javaappend two arrays javaarrays concat javahow to connect two arrays in javaconcatenate two arrays in java