My code is:
int total = 10;
int[] myArray = new int [total];
System.out.println("Enter numbers. To stop, enter 0.")
int numbers = input.nextInt();
while (numbers != 0) {
for (int i = 0; i < total; i ++)
myArray[i] = numbers;
numbers = input.nextInt();
}
for (int i = 0; i < myArray.length; i++)
System.out.print(myArray[i] + ", ") //This line only prints the last number I enter 10 times.
I want to be able to print the whole array with the numbers I entered. For example:
I enter: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0
But the result I get is: 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
EDIT: I don't get why my question has been marked a duplicate? I tried searching everywhere on this site for a similar question and haven't found one so that's why I asked. Isn't this the purpose of this site?
EDIT 2: Fine. I see how it is. I'll take my questions to some other more helpful sites. Thank you for your "service" Stack Exchange.