Trouble with Scanner Java -


i writting program needs gather block of digits , it. reason, scanner cannot read inputted digits. wrong?

int = 0; while (i >=0){     system.out.println(sc.nextint());     i++; } 

input:

3 100 3 5 75 25 200 7 150 24 79 50 88 345 3 8 8 2 1 9 4 4 56 90 3 

output:

3 100 3 5 75 25 200 7 150 24 79 50 88 345 3 8 8 

it missing last 8 digits. why this?

for getting integers from user, scanner work until user enters character or except integer in code.

        try {             arraylist<integer> ar=new arraylist<integer>();             scanner s = new scanner(system.in);             system.out.println("enter character , press enter exit!!");             while(s.hasnextint())             {                 ar.add(s.nextint());             }              for(int i:ar)             {                 system.out.println(i);             }         } catch (exception e) {             e.printstacktrace();         } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -