Mohamed Sanaulla wrote:"ten" is not same as entering- 10. nextInt() expects 10 and not "ten".
And as far as the infinite loop is considered- success never becomes true, because there's an exception thrown, catch block tackles it and the loop continues. You can step through a debugger to check the behavior of the program
Hello Mohamed, well thanks for your reply but the problem is that I have entered ten on purpose. Haven't I mentioned that I get an InputMismatchException? Thanks for trying, but I already know the difference between ten and 10. Please read the entire question. Thanks again.