package test;
import java.util.*;
public class six_thirteen {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("请输入你的年龄:");
int age = reader.nextInt();
System.out.println(age);
}
}
请问一下大神现在有一个警告Resource leak: 'reader' is never closed,是什么原因?应该怎么改?
标签:
try{
System.out.println("请输入你的年龄:"); int age = reader.nextInt(); System.out.println(age);
}finally
{
reader.close();
}