Java Utililty Methods Number Range Create

List of utility methods to do Number Range Create

Description

The list of methods to do Number Range Create are organized into topic(s).

Method

int[]range(int start, int end)
Return an integer array containing consecutive integers from a given start value upto (but not including) a given end value.
int[] rs = new int[Math.abs(end - start)];
for (int i = start; i < end; ++i) {
    rs[i - start] = i;
return rs;
Integer[]range(int start, int end)
range
if (start > end) {
    throw new IllegalArgumentException(String.format("[%d, %d) illegal coordinates.", start, end));
Integer[] array = new Integer[end - start];
for (int i = start, j = 0; i < end; i++, j++) {
    array[j] = i;
return array;
...
int[]range(int start, int end)
Returns an array of all integers [start..end) exclusive.
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;
int[]range(int start, int end)
range
return range(start, end, false);
int[]range(int start, int end)
range
int[] range = new int[end - start];
for (int i = start; i < end; i++)
    range[i - start] = i;
return range;
int[]range(int start, int end, int step)
Creates a sequence of elements from start to end (omited) with the step given.
if (end <= start) {
    throw new RuntimeException("end must be greater than start!");
int n = (int) Math.ceil((end - start) / ((float) step));
int[] seq = new int[n];
seq[0] = start;
for (int i = 1; i < n; i++)
    seq[i] = seq[i - 1] + step;
...
int[]range(int start, int length)
range
int[] range = new int[length - start + 1];
for (int i = start; i <= length; i++) {
    range[i - start] = i;
return range;
int[]range(int start, int length, int step)
range
int[] a = new int[length];
for (int i = 0; i < length; i++)
    a[i] = start + step * i;
return a;
int[]range(int start, int stop)
range
return range(start, stop, 1);
int[]range(int startValue, int endValue)
Return an array with values enumerated through the given range
int[] array = new int[endValue - startValue + 1];
for (int i = 0; i < endValue - startValue + 1; i++) {
    array[i] = startValue + i;
return array;