Resource leak: ‘in’ is never closed

Why does Eclipse give me the warming “Resource leak: ‘in’ is never closed” in the following code?

public void readShapeData() {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the width of the Rectangle: ");
        width = in.nextDouble();
        System.out.println("Enter the height of the Rectangle: ");
        height = in.nextDouble();

Leave a Comment