资源泄漏:“in"永远不会关闭 [英] Resource leak: 'in' is never closed
本文介绍了资源泄漏:“in"永远不会关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 Eclipse 在下面的代码中给我温暖的资源泄漏:'in'从未关闭"?
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();
推荐答案
因为你没有关闭你的 Scanner
Because you don't close your Scanner
in.close();
这篇关于资源泄漏:“in"永远不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文