Java Array Copy copyArray()

Here you can find the source of copyArray()

Description

copy Array

License

Open Source License

Declaration

public static int[] copyArray() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int[] copyArray() {

        int[] array = new int[10];
        for (int i = 0; i < array.length; i++) {
            array[i] = (int) (Math.random() * 10);
        }//from   w w  w .  ja va  2 s. c om
        int[] newArray = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i];
        }
        System.out.println("Original Array: ");
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        System.out.println("New Array:");
        for (int i = 0; i < array.length; i++) {
            System.out.println(newArray[i]);
        }
        return newArray;
    }
}

Related

  1. copy(T[] array)
  2. copy(T[] array)
  3. copy2DArray(char[][] original)
  4. copy5DArray(char[][][][][] original)
  5. copyAndFillOf(T[] original, int newLength, T padding)
  6. copyArray(byte[] dest, int off, byte[] src)
  7. copyArray(byte[] original, int start, int length)
  8. copyArray(byte[] out, byte[] in, int idx)
  9. copyArray(double[] a)