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

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

Description

Return an integer array containing consecutive integers from a given start value upto (but not including) a given end value.

License

Open Source License

Parameter

Parameter Description
start The start value from which the range begins. This value is always the first element of the final array (assuming it's not empty).
end The value up to which (exclusively) the range extends. This value is not in the final array. If this value equals or is less than the start value, then the empty array is returned.

Declaration

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

Method Source Code

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

public class Main {
    /**//from w  ww  .ja  v  a2  s  . c o m
     * Return an integer array containing consecutive integers from a given
     * start value upto (but not including) a given end value.
     *
     * @param start
     *            The start value from which the range begins. This value is
     *            always the first element of the final array (assuming it's not
     *            empty).
     * @param end
     *            The value up to which (exclusively) the range extends. This
     *            value is not in the final array. If this value equals or is
     *            less than the start value, then the empty array is returned.
     * @return
     */
    public static int[] range(int start, int end) {
        int[] rs = new int[Math.abs(end - start)];
        for (int i = start; i < end; ++i) {
            rs[i - start] = i;
        }
        return rs;
    }
}

Related

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