Android Utililty Methods Array Copy

List of utility methods to do Array Copy

Description

The list of methods to do Array Copy are organized into topic(s).

Method

int[]copyOf(int[] obj)
copy Of
return copyOf(obj, obj.length);
int[]copyOf(int[] obj, int newSize)
copy Of
int tempArr[] = new int[newSize];
System.arraycopy(obj, 0, tempArr, 0, Math.min(obj.length, newSize));
return tempArr;
int[][]copyOf(int[][] obj)
copy Of
int size = obj.length;
int[][] copy = new int[size][];
for (int i = 0; i < size; i++) {
    int len = obj[i].length;
    int[] res = new int[len];
    System.arraycopy(obj[i], 0, res, 0, len);
    copy[i] = res;
return copy;
long[]copyOf(long[] obj)
copy Of
return copyOf(obj, obj.length);
long[]copyOf(long[] obj, int newSize)
copy Of
long tempArr[] = new long[newSize];
System.arraycopy(obj, 0, tempArr, 0, Math.min(obj.length, newSize));
return tempArr;
byte[]copyOfRange(final byte[] source, final int from, final int to)
copy Of Range
final byte[] range = new byte[to - from];
System.arraycopy(source, from, range, 0, range.length);
return range;
int[]copy(int[] rSource)
copy
int[] aResult = new int[rSource.length];
System.arraycopy(rSource, 0, aResult, 0, aResult.length);
return aResult;
voidcopy(float[] src, Buffer dst, int numFloats, int offset)
copy
copyJni(src, dst, numFloats, offset);
dst.position(0);
if (dst instanceof ByteBuffer)
    dst.limit(numFloats << 2);
else if (dst instanceof FloatBuffer)
    dst.limit(numFloats);
String[]appendWhereArgsToSelectionArgs( String[] selectionArgs, String[] whereArgs)
append Where Args To Selection Args
if (whereArgs == null || whereArgs.length == 0) {
    return selectionArgs;
if (selectionArgs == null || selectionArgs.length == 0) {
    return whereArgs;
final String[] result = new String[selectionArgs.length
        + whereArgs.length];
...
voidarraycopy(String src, int srcOffset, byte[] dst, int dstOffset, int length)
arraycopy
if (src == null || dst == null) {
    throw new NullPointerException("invalid byte array ");
if ((src.length() < (srcOffset + length))
        || (dst.length < (dstOffset + length))) {
    throw new IndexOutOfBoundsException("invalid length: " + length);
for (int i = 0; i < length; i++) {
...