Exception in thread main java.util.NoSuchElementException: No line found

Exception in thread main java.util.NoSuchElementException: No line found

The API document of readLine() method says as below

Throws:
    NoSuchElementException - if no line was found 

You are supposed to handle this exception or just use the hasNextLine() method to avoid the exception.

while(sc.hasNextLine()){
    requestedSeat = sc.nextLine();
}

Exception in thread main java.util.NoSuchElementException: No line found

Leave a Reply

Your email address will not be published.