Here you can find the source of arrayCopy(int[] x)
private static int[] arrayCopy(int[] x)
//package com.java2s; //License from project: Open Source License public class Main { private static int[] arrayCopy(int[] x) { int z = 0; int[] l = new int[x.length + 1]; for (int i = 0; i < x.length; i++) { int y = x[i]; if (y != 0) { l[z] = y;/* ww w .j a v a 2 s . co m*/ z++; } } int[] n = new int[z]; System.arraycopy(l, 0, n, 0, z); return n; } }