With Java 8 it is so simple so it doesn’t even need separate method anymore:
List<Integer> range = IntStream.rangeClosed(start, end)
.boxed().collect(Collectors.toList());
More Related Contents:
- Google Guava vs. Apache Commons [closed]
- Map that could be iterated in the order of values
- Does Java JIT compiler sacrifice performance to favor Collections?
- Converting ‘ArrayList to ‘String[]’ in Java
- How can I convert List to int[] in Java? [duplicate]
- How to convert int[] into List in Java?
- Convert an array of primitive longs into a List of Longs
- How to convert an Array to a Set in Java
- How can I convert int[] to Integer[] in Java?
- How can I get the size of an array, a Collection, or a String in Java?
- Lambda expression to convert array/List of String to array/List of Integers
- Combine multiple Collections into a single logical Collection?
- Java – generate Random range of specific numbers without duplication of those numbers – how to?
- How to Serialize a list in java?
- Why does Collections.sort use Mergesort but Arrays.sort does not?
- builder for HashMap
- Java: how to convert HashMap to array
- Print array without brackets and commas
- The easiest way to transform collection to array?
- Bi-directional Map in Java? [duplicate]
- ArrayList: how does the size increase?
- How to create ArrayList (ArrayList) from array (int[]) in Java
- Iterate through string array in Java
- How to do map inversion with Guava with non-unique values?
- How to convert an int[] array to a List?
- What are the differences between a HashMap and a Hashtable in Java?
- Where is array’s length property defined?
- Can an array be used as a HashMap key?
- Easy way to convert Iterable to Collection
- What is the Simplest Way to Reverse an ArrayList?