Java array copy using System.arraycopy()

Description

Java array copy using System.arraycopy()

import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    int[] intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };

    int[] arrayCopy = new int[intArray.length];

    System.out.println(Arrays.toString(intArray));
    /*  w w w . j  a  v  a2  s  .  c om*/
    System.arraycopy(intArray, 0, arrayCopy, 0, intArray.length);

    System.out.println(Arrays.toString(arrayCopy));
  }
}



PreviousNext

Related