为什么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'其通常不期望的。 –
@StuartCook +1。有些东西要留意。 – informatik01
为什么我们需要关闭扫描仪? “资源泄漏”是什么意思? –