Android Array Remove removeInt(int[] cur, int val)

Here you can find the source of removeInt(int[] cur, int val)

Description

remove Int

Declaration

public static int[] removeInt(int[] cur, int val) 

Method Source Code

//package com.java2s;

public class Main {
    public static int[] removeInt(int[] cur, int val) {
        if (cur == null) {
            return null;
        }/*from   w  w  w . ja v a2  s  .c o m*/
        final int N = cur.length;
        for (int i = 0; i < N; i++) {
            if (cur[i] == val) {
                int[] ret = new int[N - 1];
                if (i > 0) {
                    System.arraycopy(cur, 0, ret, 0, i);
                }
                if (i < N - 1) {
                    System.arraycopy(cur, i + 1, ret, i, N - i - 1);
                }
                return ret;
            }
        }
        return cur;
    }
}

Related

  1. removeElement(double[] array, double element)
  2. removeElement(float[] array, float element)
  3. removeElement(int[] array, int element)
  4. removeElement(long[] array, long element)
  5. removeElement(short[] array, short element)