I am new to Java. Can anyone tell me how to remove this resource leak error? The error says the resource leak is never closed.
If you are using Java 7+ version you can use try with resources like the below.
public static void main(String args[]) {
try (Scanner in = new Scanner(System.in)) {
System.out.println("Enter a number - ");
int n = in.nextInt();
System.out.println("N is " + n);
}
}