Java Number Range Create range(int startValue, int endValue)

Here you can find the source of range(int startValue, int endValue)

Description

Return an array with values enumerated through the given range

License

Open Source License

Parameter

Parameter Description
startValue first value for the array
endValue last value for the array

Declaration

public static int[] range(int startValue, int endValue) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w.j  a  va2  s  .c  om*/
 *  Java Information Dynamics Toolkit (JIDT)
 *  Copyright (C) 2012, Joseph T. Lizier
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Return an array with values enumerated through the given range
     * 
     * @param startValue first value for the array
     * @param endValue last value for the array
     * @return
     */
    public static int[] range(int startValue, int endValue) {
        int[] array = new int[endValue - startValue + 1];
        for (int i = 0; i < endValue - startValue + 1; i++) {
            array[i] = startValue + i;
        }
        return array;
    }
}

Related

  1. range(int start, int end)
  2. range(int start, int end, int step)
  3. range(int start, int length)
  4. range(int start, int length, int step)
  5. range(int start, int stop)
  6. range(int unit)
  7. range(int v, int min, int max)
  8. range(int value, int min, int max)
  9. range(Integer from, Integer to)