xp系统的回车键的值为\r\n 所以那怕你直接敲回车都会输出
13
10
代码改成如下就可以了
public class putInprint {
public static void main(String[] args) throws Exception {
int x = System.in.read();
while (x != 'a' ) {
if(x!='\r' && x!='\n') //回车不打印
System.out.println(x);
x = System.in.read();
可以把代码修改一下:
public class C{
public static void main(String[] args) throws Exception{
int x= System.in.read();
while(x!='a'){
x=System.in.read();
switch(x) {
case !='/r':
break;
case !='/n':
break;
default:
System.out.println(x);
}
}
}
}