Java Number Range Create range(int low, int high)

Here you can find the source of range(int low, int high)

Description

range

License

Open Source License

Parameter

Parameter Description
low the lowest integer in the range
high the highest integer in the range

Return

an array of all the values between low (inclusive) and high (inclusive) in order

Declaration

public static int[] range(int low, int high) 

Method Source Code

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

public class Main {
    /**/*from  ww w.ja  v a  2 s.co m*/
     * @param low the lowest integer in the range
     * @param high the highest integer in the range
     * @return an array of all the values between low (inclusive) and high
     * (inclusive) in order
     */
    public static int[] range(int low, int high) {
        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;
    }
}

Related

  1. range(int from, int to)
  2. range(int from, int to)
  3. range(int from, int to)
  4. range(int i, int j)
  5. Range(int k, int from, int end)
  6. range(int min, int max)
  7. range(int min, int max)
  8. range(int min, int max, int value)
  9. range(int n)