I am a Java Beginner.
I got an error when running this code.
It says the following error: Resource Leak: 'yourName' is never closed.
And i am using VS Code insiders.
The file name is PrintName.java and the code is -->
import java.util.*;
public class PrintName {
public static void main(String[] args) {
// Prints your name
System.out.print("What is your name? ");
Scanner yourName = new Scanner(System.in);
System.out.println("Your name is: " + yourName.next());
}
}
And.. could anyone help me with the solution please?