Java tutorial
//package com.java2s; public class Main { public static int[] removeInt(int[] cur, int val) { if (cur == null) { return null; } 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; } }