Here you can find the source of range(int from, int to)
Parameter | Description |
---|---|
from | a parameter |
to | a parameter |
public static int[] range(int from, int to)
//package com.java2s; /**//from w w w. ja v a 2s .c om * Get a short description of the licensing terms. */ public class Main { /** * Generates an array of integers in range from 'from' to 'to'-1; * * @param from * @param to * @return */ public static int[] range(int from, int to) { if (from > to) { throw new IllegalArgumentException( String.format("Invalid 'from' (%d) and 'to' (%d) values.", from, to)); } int count = to - from; int[] r = new int[count]; for (int i = 0; i < count; i++) { r[i] = from; from++; } return r; } }