I\'ve been trying to print the output in two separate lines, I used System.out.println()
and also System.out.println(\"\\n\")
but I only seem to be get
The line:
String in = input.nextLine();
is capturing your first number entered and it is never added to the list al.
So, if you enter:
45
40
67
0
the output is:
[40, 67] (using System.out.println(al))
or:
4067 (using your for loop).
Note, the loop is broken by entering 0, not non-numeric characters as the first output text line would suggest.
Read lines, please enter some other character to stop
should really read
Read lines, please enter 0 to stop
[EDIT]
To add/display numbers to the list correctly:
1) Remove the line:
String in = input.nextLine();
2) Remove the for loop at the end and replace it with:
System.out.println(al);