very simple 输入功能测试,但运行结果很奇怪
初学java,发现输入输出不方便,欲做一个自己的输入类
结果很恼火,请各位不吝赐教,大谢!
//试验:从键盘输入几个数
//每输入一个就在显示器上显示
//10.31日,问题:每执行一次它跳过三个循环
import java.io.*;
public class Expri
{
public Expri()
{
System.out.println("===========================");
}
public static void main(String[] args) throws IOException
{
int tem;
for(int i=0;i<10;i++)
{
System.out.println("Please input your number:");
tem=System.in.read();
System.out.println("the number you input is:"+tem);
}
}
}
问题点数:20、回复次数:4Top
1 楼dylsz(东阳江)回复于 2003-11-01 14:16:32 得分 20
tem=System.in.read();读取输入的下一个字节。
一个回车算两个字节。
总共可以读取10个字节Top
2 楼godsmother(大悟)回复于 2003-11-01 15:17:36 得分 0
多谢,咱老思维还停留在面向过程编程Top
3 楼lahu0578(牙笑)回复于 2003-11-01 16:22:14 得分 0
程序运行结果和解释:
D:\jdk1.3.1\bin>java Expri
Please input your number:
123456
the number you input is:49 //1的码值
Please input your number:
the number you input is:50 //2的码值
Please input your number:
the number you input is:51 //3的码值
Please input your number:
the number you input is:52 //4的码值
Please input your number:
the number you input is:53 //5的码值
Please input your number:
the number you input is:54 //6的码值
Please input your number:
the number you input is:13 //回车的码值
Please input your number:
the number you input is:10 //换行的码值
************
enter相当于回车换行Top
4 楼godsmother(大悟)回复于 2003-11-01 22:59:01 得分 0
thanks to lahu0578 all the same!Top
相关问题
- DBEdit运行后怎么没法输入?
- 运行时怎么需要输入exe文件明
- 为什么运行时文本框中不能输入中文???
- 难道用户运行程序也需要输入:java classname....吗?
- eclipse 怎么运行输入参数的应用程序
- 我在命令提示符下输入命令,程序运行后提示用户输入,输入后程序继续运行,请问用什么语句
- 我在“运行”下输入“cmd”后到当前盘符下,却不能运行ping,arp,等很多命令!
- 为何输入法在win2000都无法运行(如五笔型输入法、万全新拼音),这是为何?
- 哪里有C#,Winform程序运行时首先弹出输入用户名和密码输入框的示例?
- 求救!xp的运行项输入框中不能输入空格斜线等特殊字符




