我在Java 6上。DataInputStream in = new DataInputStream(System.in);
用于读取用户输入。不推荐使用readLine()的情况。读取用户价值的方法是什么?
DataInputStream in = new DataInputStream(System.in);
int num;
try
{
num = Integer.parseInt(in.readLine()); //this works
num = Integer.parseInt(in); //just in doesnt work.
}
catch(Exception e)
{
}
请在不建议使用readLine()时进行解释。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句