Here you can find the source of range(int start, int end)
Parameter | Description |
---|---|
start | The start value from which the range begins. This value is always the first element of the final array (assuming it's not empty). |
end | The value up to which (exclusively) the range extends. This value is not in the final array. If this value equals or is less than the start value, then the empty array is returned. |
public static int[] range(int start, int end)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww .ja v a2 s . c o m * Return an integer array containing consecutive integers from a given * start value upto (but not including) a given end value. * * @param start * The start value from which the range begins. This value is * always the first element of the final array (assuming it's not * empty). * @param end * The value up to which (exclusively) the range extends. This * value is not in the final array. If this value equals or is * less than the start value, then the empty array is returned. * @return */ public static int[] range(int start, int end) { int[] rs = new int[Math.abs(end - start)]; for (int i = start; i < end; ++i) { rs[i - start] = i; } return rs; } }