0

I have this:

import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d = scan.nextDouble();
        String s = scan.next();
        
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
}

Output: Resource leak: 'scan' is never closedJava(536871799)

What is wrong with my code?

1 Answers1

0

Very simple. Once you no longer need the scanner, just run scan.close();. That's it. Have a great day!

CiY3
  • 134
  • 10