Android Array Add appendInt(int[] cur, int val)

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

Description

append Int

Declaration

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

Method Source Code

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

Related

  1. addAll(int[] array1, int... array2)
  2. addAll(long[] array1, long... array2)
  3. addAll(short[] array1, short... array2)
  4. append(String[] original, String element)
  5. appendElement(Class kind, T[] array, T element)
  6. arrayappend(T[] array, T[] append)
  7. arrayappend(T[] array, T[] append, int size)
  8. arraybyteappend(byte[] array, byte[] append)
  9. arraybyteappend(byte[] array, byte[] append, int size)