I would like to fill an array using consecutive integers. I have created an array that contains as much indexes as the user enters:
Scanner in = new Scanner(
Scanner in = new Scanner(System.in); int numOfValues = in.nextInt(); int[] array = new int[numOfValues]; int add = 0; for (int i = 0; i < array.length; i++) { array[i] = 1 + add; add++; System.out.println(array[i]); }