0
Input Monument infinity loop
System. out. println("Insert monument:") ; while(sc. hasNextInt()) { int1.add(sc.nextInt()); } This is part of my code. If example I enter 1 3 4 5 and press Enter the program does not give me an error but does not continue. Thanks.
5 Antworten
0
It shouldn't result in an infinite loop. What exactly isn't working there? Can you post the entire code?
https://code.sololearn.com/ctVlm8xMQtXa/?ref=app
0
Ok 10 minutes and I send the entire code. Thanks
0
If you rewrite the bad part I thank you.
0
I've been considering only the part you referred to. And it appears that the problem is in the if condition (line 25-27). Considering only this snippet the while should result in true as long as the next token is an int. I personally don't see much utility in having an extra exit condition there, but then again I looked at the other parts of the code only briefly.
https://code.sololearn.com/cvoHU0Ti9nh4/?ref=app