Here you can find the source of clone(int[] in)
public static final int[] clone(int[] in)
//package com.java2s; //License from project: Apache License public class Main { public static final int[] clone(int[] in) { int nx = in.length; int[] out = new int[nx]; for (int i = 0; i < nx; i++) { out[i] = in[i];/*from ww w .ja v a 2 s . c om*/ } return out; } public static final float[] clone(float[] in) { int nx = in.length; float[] out = new float[nx]; for (int i = 0; i < nx; i++) { out[i] = in[i]; } return out; } public static final byte[] clone(byte[] in) { int nx = in.length; byte[] out = new byte[nx]; for (int i = 0; i < nx; i++) { out[i] = in[i]; } return out; } public static final double[] clone(double[] in) { int nx = in.length; double[] out = new double[nx]; for (int i = 0; i < nx; i++) { out[i] = in[i]; } return out; } public static final int[][] clone(int[][] in) { int nx = in.length; int ny = in[0].length; int[][] out = new int[nx][ny]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) { out[i][j] = in[i][j]; } return out; } public static final float[][] clone(float[][] in) { int nx = in.length; int ny = in[0].length; float[][] out = new float[nx][ny]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) { out[i][j] = in[i][j]; } return out; } public static final double[][] clone(double[][] in) { int nx = in.length; int ny = in[0].length; double[][] out = new double[nx][ny]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) { out[i][j] = in[i][j]; } return out; } public static final int[][][] clone(int[][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; int[][][] out = new int[nx][ny][nz]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < nz; k++) { out[i][j][k] = in[i][j][k]; } return out; } public static final double[][][] clone(double[][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; double[][][] out = new double[nx][ny][nz]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < nz; k++) { out[i][j][k] = in[i][j][k]; } return out; } public static final float[][][] clone(float[][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; float[][][] out = new float[nx][ny][nz]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < nz; k++) { out[i][j][k] = in[i][j][k]; } return out; } public static final double[][][][] clone(double[][][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; int nc = in[0][0][0].length; double[][][][] out = new double[nx][ny][nz][nc]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < nz; k++) for (int l = 0; l < nc; l++) { out[i][j][k][l] = in[i][j][k][l]; } return out; } public static final float[][][][] clone(float[][][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; int nc = in[0][0][0].length; float[][][][] out = new float[nx][ny][nz][nc]; for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < nz; k++) for (int l = 0; l < nc; l++) { out[i][j][k][l] = in[i][j][k][l]; } return out; } }