Scanner close() method in Java with Examples
The close() method ofjava.util.Scanner class closes the scanner which has been opened. If the scanner is already closed then on calling this method, it will have no effect.
public void close()
Return Value: The function does not return any value.
Below programs illustrate the above function:
Scanner: Geeksforgeeks has Scanner Class Methods Scanner Closed. Trying to use scanner after closing. Exception thrown: java.lang.IllegalStateException: Scanner closed
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.