什么是:
System.in.read()
返回 ?这文档 says :
返回:
数据的下一个字节,如果到达流末尾则为 -1。
49
是字符的 ASCII 值1
。它是第一个字节的值。
The stream of bytes that is produced when you enter 10Enter on your console or terminal contains the three bytes {49,48,10}
(on my Mac, may end with 10,12 or 12 instead of 10, depending on your System).
所以简单片段的输出
int b = System.in.read();
while (b != -1) {
System.out.println(b);
b = System.in.read();
}
输入 10 并按 Enter 键后,是(在我的机器上)
49
48
10
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)