为什么Eclipse在以下代码中给我加温的“资源泄漏:'in'永远不会关闭”?
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();
Scanner
和使警告静音,但也将关闭System.in
,通常这是不希望的。