Scanner NoSuchElementException

You have more than one Scanner that you close, which closes the underlying InputStream, therefore another Scanner can no longer read from the same InputStream and a NoSuchElementException results.

For console apps, use a single Scanner to read from System.in.

Leave a Comment