【发布时间】:2012-11-07 08:33:42
【问题描述】:
当我运行以下代码并在提示输入时键入 50:
private static int nPeople;
public static void main(String[] args) {
nPeople = 0;
System.out.println("Please enter the amount of people that will go onto the platform : ");
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
try {
nPeople = keyboard.read();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(" The number of people entered --> " + nPeople);
}
}
我得到以下输出:
请输入进入平台的人数:50 输入人数 --> 53
为什么当我输入 50 时它返回 53 ?谢谢。
【问题讨论】:
-
什么是
keyboard以及read()方法的具体作用是什么?
标签: java input io bufferedreader