Java添加两个数组


Java添加两个数组

import java.util.Arrays;



public class ArrayConcate {

   public static void main(String[] args) {

      int[] a1 = {8,9,5,7,8};

      int[] a2 = {12,78,96};

      int len_a = a1.length;

      int len_b = a2.length;

      int[] result = new int[len_a + len_b];



      System.arraycopy(a1, 0, result, 0, len_a);

      System.arraycopy(a2, 0, result, len_a, len_b);

      System.out.println(Arrays.toString(result));

   }

}