[Solved] why does the error”java.util.NoSuchElementException” get thrown? [closed]


Scanner#next reads a whole token, not a character. Inside your for loop

arr += scan.next();

consumes the UDDDUDUU on the first pass. There is nothing left to read on the second pass. Thus, java.util.NoSuchElementException.

4

solved why does the error”java.util.NoSuchElementException” get thrown? [closed]