Java Number Range Create range(int start, int end)

Here you can find the source of range(int start, int end)

Description

Returns an array of all integers [start..end) exclusive.

License

Open Source License

Parameter

Parameter Description
start the value at the first position in the array
end the value at the last position in the array

Return

the array of integers [start..end)

Declaration

public static int[] range(int start, int end) 

Method Source Code

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

public class Main {
    /**//  w  ww . ja v  a  2  s  .  c om
     * Returns an array of all integers [start..end) exclusive.
     *
     * @param start the value at the first position in the array
     * @param end   the value at the last position in the array
     * @return the array of integers [start..end)
     */
    public static int[] range(int start, int end) {
        final int size = end - start;
        final int[] array = new int[size];
        for (int i = 0; i < array.length; i++) {
            array[i] = i + start;
        }
        return array;
    }
}

Related

  1. range(int min, int max, int value)
  2. range(int n)
  3. range(int start, int end)
  4. range(int start, int end)
  5. range(int start, int end)
  6. range(int start, int end)
  7. range(int start, int end, int step)
  8. range(int start, int length)
  9. range(int start, int length, int step)