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();
}

Leave a Comment