/** * @author lautturi.com * Java example: java merge two arrays using Apache Commons Lang library. */ import java.util.*; import org.apache.commons.lang3.ArrayUtils; // using Apache Commons Lang library. public class Lautturi { public static void main(String[] args) { int[] arr1 = {1, 3, 5, 2, 4}; int[] arr2 = { 1,4,2,7,5,16,12,8,13,28 }; int[] both = ArrayUtils.addAll(arr1, arr2); System.out.println("new array:"+Arrays.toString(both)); } }
output:
new array:[1, 3, 5, 2, 4, 1, 4, 2, 7, 5, 16, 12, 8, 13, 28]