Android Utililty Methods Array Range Copy

List of utility methods to do Array Range Copy

Description

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

Method

T[]copyOfRange(T[] original, int from, int to)
copy Of Range
return Arrays.copyOfRange(original, from, to,
        (Class<T[]>) original.getClass());
T[]copyOfRange(T[] original, int start, int end)
copy Of Range
int originalLength = original.length; 
if (start > end) {
    throw new IllegalArgumentException();
if (start < 0 || start > originalLength) {
    throw new ArrayIndexOutOfBoundsException();
int resultLength = end - start;
...
T[]copyOfRange(U[] original, int from, int to, Class newType)
copy Of Range
int newSize = to - from;
if (newSize < 0) {
    throw new IllegalArgumentException(from + " > " + to);
T[] copy = (Object) newType == (Object) Object[].class ? (T[]) new Object[newSize]
        : (T[]) Array.newInstance(newType.getComponentType(),
                newSize);
System.arraycopy(original, from, copy, 0,
...
byte[]copyOfRange(byte[] original, int from, int to)
Copies the specified range of the specified array into a new array.
int newLength = to - from;
if (newLength < 0)
    throw new IllegalArgumentException(from + " > " + to);
byte[] copy = new byte[newLength];
System.arraycopy(original, from, copy, 0,
        Math.min(original.length - from, newLength));
return copy;
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;
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;