Java Number Range Create range(int i, int j)

Here you can find the source of range(int i, int j)

Description

TODO: Doc

License

Apache License

Parameter

Parameter Description
i a parameter
j a parameter

Declaration

public static int[] range(int i, int j) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from www  .  j a  v  a  2  s  . c  om*/
     * TODO: Doc
     * @param i
     * @param j
     * @return
     */
    public static int[] range(int i, int j) {
        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;
        }

        return r;
    }

    /**
     * TODO: Doc
     * @param n
     * @return
     */
    public static int[] range(int n) {
        return range(0, n);
    }
}

Related

  1. range(int end)
  2. range(int excludedEnd)
  3. range(int from, int to)
  4. range(int from, int to)
  5. range(int from, int to)
  6. Range(int k, int from, int end)
  7. range(int low, int high)
  8. range(int min, int max)
  9. range(int min, int max)