Java Array Copy arrayCopy(int[] x)

Here you can find the source of arrayCopy(int[] x)

Description

array Copy

License

Open Source License

Declaration

private static int[] arrayCopy(int[] x) 

Method Source Code

//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;
    }
}

Related

  1. arrayCopy(double[][] src)
  2. arrayCopy(final byte[] src, final byte[] dest)
  3. arrayCopy(final float[] arrayToCopy)
  4. arrayCopy(int[] array, int i0, int n, boolean isReverse)
  5. arrayCopy(int[] array, int length)
  6. arrayCopy(int[][] source, int[][] destination)
  7. arraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit)
  8. arraycopy(long[] src, int srcPos, long[] dest, int destPos, int length)
  9. arraycopy(Object dest, Object src1, int length1, Object src2, int length2)