shortest way of filling an array with 1,2…n May 4, 2023 by Tarik Since Java 8 this is possible: int[] a = IntStream.range(1, 100).toArray(); (And shorter than the other java 8 answer .).