Java Array array_intAddLimit(int[] in, int value, int limit)

Here you can find the source of array_intAddLimit(int[] in, int value, int limit)

Description

arraint Add Limit

License

Open Source License

Declaration

public static int[] array_intAddLimit(int[] in, int value, int limit) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int[] array_intAddLimit(int[] in, int value, int limit) {
        int[] ret = new int[Math.min(in.length + 1, limit)];
        System.arraycopy(in, Math.max(0, in.length - limit), ret, 0,
                in.length);//from ww  w .  j  a  va2 s .  c  o  m
        ret[Math.min(in.length, limit - 1)] = value;
        return ret;
    }
}

Related

  1. array_equals(byte[] foo, byte bar[])
  2. array_int2float(int ai[])
  3. arrayed(int arrays, String inner)
  4. arrayEndsWith(final byte[] array, final byte[] str)
  5. arrayExclude(double[] src, int excludeIndex)
  6. arrayFirstIndexOf(final T[] array, final T value)