一个小程序!
class Demo
{
public static void main(String[] args) throws Exception
{
int a=0;
w:while(true){
for(int i=0; i<3; i++){
int ch=System.in.read();
if(ch=='x')
continue w;
else if(ch=='y')
break w;
else
System.out.print((char)ch+""+(++a));
}
System.out.println(">");
}
System.out.println();
}
}为什么在DOS命令行中输入abcde
结果是
abcde
a1b2c3>
6>e57
d为什么没有输出?
如果输入abcdef
abcdef
a1b2c3>
d4e5f6>
7
8
输出结果比较费解,哪位达人可以详细的讲解一下读取流程?
先谢过!
class Demo
{
public static void main(String[] args) throws Exception
{
int a=0;
w:while(true){
for(int i=0; i<3; i++){
int ch=System.in.read();
if(ch=='x')
continue w;
else if(ch=='y')
break w;
else
System.out.print((char)ch+""+(++a));
}
System.out.println(">");
}
System.out.println();
}
}为什么在DOS命令行中输入abcde
结果是
abcde
a1b2c3>
6>e57
d为什么没有输出?
如果输入abcdef
abcdef
a1b2c3>
d4e5f6>
7
8
输出结果比较费解,哪位达人可以详细的讲解一下读取流程?
先谢过!
解决方案 »
- 我想了解一下java各个基本类,常用类的继承关系,有推荐吗?
- 关于字节流的写入与读取
- 如何将已经用字节方式存入文件的图片转换成 BufferedImage
- eclipse提示:标记“createPool”上有语法错误,在此标记之后应为 Identifier???
- (学JAVA的都进来.........)runtime exception与Compile time error有什么区别!
- 一个入门问题(关于文本输入框的)
- Tomcat 配置能浏览目录结构时,能否通过配置浏览单个目录,而不是浏览整个tomcat目录结构?另外,怎样配置才能只浏览虚拟目录的目录结构
- 请问ListIterator和Iterator有何区别!!
- spring 如何与hibernate 结何呀?
- 初级问题.....
- 菜菜的问题,请高手指教
- 如何替换掉JSP页面中的<br/>?
BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
String readline = sin.readLine();