Ah, I understand what you meant now.
The problem is this: nextInt() reads the next integer, which are separated by white space. The enter key counts as white space, so it isn't read in when you...
Type: Posts; User: KevinWorkman
Ah, I understand what you meant now.
The problem is this: nextInt() reads the next integer, which are separated by white space. The enter key counts as white space, so it isn't read in when you...
If the sc.nextInt() function throws an Exception (which it will if you enter a double), then the i++ line will not be executed.
Step through this with a debugger, or at least add some print...
Have you tried putting it in a loop?