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

[ad_1]

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

[ad_2]

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