Java Array Sub Array subarrayOf(final String[] array, final int start, final int end)

Here you can find the source of subarrayOf(final String[] array, final int start, final int end)

Description

Returns a new array with the elements between [start, end).

License

Open Source License

Parameter

Parameter Description
array The array to get a subarray of.
start The start index (inclusive).
end The end index (exclusive);

Return

A new array with the elements between [start, end).

Declaration

public static String[] subarrayOf(final String[] array, final int start, final int end) 

Method Source Code

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

public class Main {
    /**/* w w w .  ja  v a  2s  . c  o  m*/
     * Returns a new array with the elements between [start, end).
     *
     * @param array
     *      The array to get a subarray of.
     * @param start
     *      The start index (inclusive).
     * @param end
     *      The end index (exclusive);
     *
     * @return
     *      A new array with the elements between [start, end).
     */
    public static String[] subarrayOf(final String[] array, final int start, final int end) {
        final int subarraySize = end - start;
        final String[] subarray = new String[subarraySize];

        for (int i = 0; i < subarraySize; ++i) {
            subarray[i] = array[i + start];
        }

        return (subarray);
    }
}

Related

  1. subArray(T[] array, int startIndex, int endIndex)
  2. subArray(T[] origin, int start, int length)
  3. subarrayChar2Double(char[] orig, int off, int len)
  4. subarrayEnd(byte[] array, int offset)
  5. subarrayEquals(int[] array, int[] subarray, int startIndex)
  6. subByteArray(byte[] array, int offset, int length)
  7. subset(boolean[] array, int start, int end)
  8. subset(byte[] a, int begin_index, int len)
  9. subset(byte[] array, int start, int length)