Here you can find the source of copyArray()
public static int[] copyArray()
//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; } }