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 from, int to)
range
if (to < from)
    throw new IllegalArgumentException("to must be larger than from");
int[] out = new int[to - from];
for (int i = 0; i < out.length; i++)
    out[i] = from + i;
return out;
long[]range(int from, int to)
range
if (to < from) {
    throw new IllegalArgumentException(
            String.format("to argument %s is less than from argument %s", to, from));
long[] array = new long[to - from + 1];
int i = 0;
for (int j = from; j <= to; j++) {
    array[i] = j;
...
int[]range(int from, int to)
Generates an array of integers in range from 'from' to 'to'-1;
if (from > to) {
    throw new IllegalArgumentException(
            String.format("Invalid 'from' (%d) and 'to' (%d) values.", from, to));
int count = to - from;
int[] r = new int[count];
for (int i = 0; i < count; i++) {
    r[i] = from;
...
int[]range(int i, int j)
TODO: Doc
if (j <= i) {
    return new int[0];
int n = j - i;
int[] r = new int[n];
int counter = 0;
for (int k = i; k < j; ++k) {
    r[counter++] = k;
...
booleanRange(int k, int from, int end)
Range
if (k < end && k >= from) {
    return true;
return false;
int[]range(int low, int high)
range
if (low > high) {
    throw new IllegalArgumentException();
int[] range = new int[high - low + 1];
for (int i = 0; i < range.length; i++) {
    range[i] = i + low;
return range;
...
int[]range(int min, int max)
Java implementation of Python's range() function, without steps
if (min > max) {
    return new int[0];
int[] rv = new int[max - min];
for (int i = 0; i < (max - min); i++) {
    rv[i] = min + i;
return rv;
...
int[]range(int min, int max)
Returns an array of the form [min, min + 1, ..., max - 1]
int[] range = new int[max - min];
for (int i = 0; i < (max - min); i++) {
    range[i] = i + min;
return range;
intrange(int min, int max, int value)
range
if (value < min) {
    value = min;
if (value > max) {
    value = max;
return value;
int[]range(int n)
range
int[] result = new int[n];
for (int i = 0; i < n; i++) {
    result[i] = i;
return result;