Java Arrays copy array

Description

Java Arrays copy array

import java.util.Arrays;

public class Main {
  public static void main(String[] args) {

    // copy array intArray into array intArrayCopy
    int[] intArray = {1, 2, 3, 4, 5, 6};
    int[] intArrayCopy = new int[intArray.length];
    System.arraycopy(intArray, 0, intArrayCopy, 0, intArray.length);
    System.out.println(Arrays.toString(intArray));
    System.out.println(Arrays.toString(intArrayCopy));

  }/*from  www .  j a va 2  s. c  o  m*/
}



PreviousNext

Related