Here you can find the source of appendInt(int[] cur, int val)
public static int[] appendInt(int[] cur, int val)
//package com.java2s; public class Main { public static int[] appendInt(int[] cur, int val) { if (cur == null) { return new int[] { val }; }/* w ww . j a v a2s .c o m*/ final int N = cur.length; for (int i = 0; i < N; i++) { if (cur[i] == val) { return cur; } } int[] ret = new int[N + 1]; System.arraycopy(cur, 0, ret, 0, N); ret[N] = val; return ret; } }