Here you can find the source of range(int excludedEnd)
public static int[] range(int excludedEnd)
//package com.java2s; //License from project: Apache License public class Main { public static int[] range(int excludedEnd) { return range(0, excludedEnd, 1); }/* ww w . j a va 2 s. c om*/ public static int[] range(int includedStart, int excludedEnd) { return range(includedStart, excludedEnd, 1); } public static int[] range(int includedStart, int excludedEnd, int step) { if (includedStart > excludedEnd) { int tmp = includedStart; includedStart = excludedEnd; excludedEnd = tmp; } if (step <= 0) { step = 1; } int deviation = excludedEnd - includedStart; int length = deviation / step; if (deviation % step != 0) { length += 1; } int[] range = new int[length]; for (int i = 0; i < length; i++) { range[i] = includedStart; includedStart += step; } return range; } }