Java Utililty Methods Array Sub Array

List of utility methods to do Array Sub Array

Description

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

Method

int[]subarray(int[] array, int start, int end)
subarray
int[] r = new int[end - start];
for (int i = start; i < end; ++i) {
    r[i - start] = array[i];
return r;
int[]subArray(int[] array, int startIndex, int theLength)
sub Array
int[] sub = new int[theLength];
for (int r = 0; r < theLength; r++) {
    sub[r] = array[startIndex + r];
return sub;
Object[]subArray(Object a[], int from)
sub Array
if (from == 0)
    return a;
Object newa[] = new Object[a.length - from];
System.arraycopy(a, from, newa, 0, newa.length);
return newa;
Object[]subArray(Object in[], int start, int end)
Return a subset of an array.
Object[] ret = new Object[end - start + 1];
int j = 0;
for (int i = start; i <= end; i++) {
    ret[j++] = in[i];
return ret;
Object[]subArray(Object[] arr, int start, int length)
Creates a subarray of arr starting at start and continuing numerically until start + length has been reached.
if (start < arr.length) {
    if (arr.length - start < length)
        length = arr.length - start;
    Object[] reply = new Object[length];
    for (int i = 0; i < length; i++) {
        try {
            reply[i] = arr[i + start];
        } catch (ArrayIndexOutOfBoundsException e) {
...
Object[]subArray(Object[] data, int startIndex, int endIndex)
Get a part on an array
Object[] output = new Object[endIndex - startIndex];
for (int i = startIndex; i < endIndex; i++) {
    output[i - startIndex] = data[i];
return output;
String[]subArray(String a[], int from)
sub Array
if (from == 0)
    return a;
String newa[] = new String[a.length - from];
System.arraycopy(a, from, newa, 0, newa.length);
return newa;
String[]subarray(String[] args, String sep)
subarray
int i = 0;
while (i < args.length && !args[i].equals("--")) {
    i++;
return copy(args, 0, i);
String[]subArray(String[] array, int start, int endExclusive)
sub Array
if (start < 0 || start > endExclusive || endExclusive > array.length)
    throw new IllegalArgumentException();
String[] result = new String[endExclusive - start];
System.arraycopy(array, start, result, 0, endExclusive - start);
return result;
String[]subArray(String[] data, int index, int length)
Returns a subarray of the given array.
if (index + length > data.length) {
    throw new IllegalArgumentException("invalid length of input array");
String[] result = new String[length];
System.arraycopy(data, index, result, 0, length);
return result;