Is there a more elegant way to create a list of all indices?
private List<Integer> getIndexList(final int count) {
final List<Integer> list = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
list.add(i);
}
return list;
}
List output:
<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>
source
to share