I have a simple for loop that asks a user to enter an integer 10 times. How can I add these inputs to an array without having to make 10 separate variables?
Scanner scan = new Scanner(System.in);
for (int i = 1; i<= 10; i++) {
System.out.println("Please enter an Integer:");
scan.nextInt();
}
}
Example Inputs: 10, 1, 3, 25, 33, 26, 12, 0, 7, 18
Desired Output: myArray = [10, 1, 3, 25, 33, 26, 12, 0, 7, 18]