How can I generate a list or array of sequential integers in Java?
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()); And in Java 16 or later: List<Integer> range = IntStream.rangeClosed(start, end) .boxed().toList();