(JAVA) Why scanner.close()?
Problem
What is the precise reason for adding sc.close(); when I use Scanner class?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Score: ");
int score = sc.nextInt();
sc.close();
}
}