How to resolve NoSuchElementException ?
And why does it occur?
NoSuchElementException
refer this post
Hi Ayush
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.
https://ide.codingblocks.com/s/71453
In the input part , when input is taken in str in loop ,it is showing a NoSuchElementException.
Exception in thread “main” java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1540)
at sortgame.main(sortgame.java:18)
I think it is because of split function.But when I run it in Eclipse IDE ,it runs perfectly fine.
Hi Ayush
What type of input are you trying to take for string? There is no need to use split() function.
st.nextLine() and st.next() does the job well.
Also, there is no need to use two scanners as well.