\r,你可以试着把\r转换为\\r,应该就能显示出来,那样能感觉只管点
(只是自我感觉,没有实验,建议你做一下实验)

解决方案 »

  1.   

    多出来的一个字符确实是回车原因如下:
    在你输入完 第一次 x 之后肯定是要按一下回车键(键盘上的键)。
    在你输入完 第二次 y 之后,你实际输入的是 回车字符加y.
    你可以执行一下下边的程序.看-看结果就知道了。(以输入第二次y的值为三个字符以上为例)
    import java.io.*;
    public class temp
    {
      public static void main (String args[])
      {
         int xcount=0,ycount=0;
         char[]x=new char[50];
         char[]y=new char[50];     //read x string
         System.out .println("please input x string");     try
           {         int temp=System.in.read();
             while (temp!=13)
             {
               x[xcount]=(char)temp;
               xcount++;
               temp=System.in.read();
               }       }
         catch(IOException e)
           {
             e.printStackTrace() ;
             }
        System.out .println(xcount);
        System.out .println(x);
         //read y string
         System.out.println("please input y string");
         try
           {         int temp=System.in.read();
             while (temp!=13)
             {
               y[ycount]=(char)temp;
               ycount++;
               temp=System.in.read();
               }       }
         catch(IOException e)
           {
             e.printStackTrace() ;
             }    System.out.println(ycount);
        System.out.println (y[0]);
        System.out.println (y[1]);
        System.out.println (y[2]);
        System.out.println (y[3]);
        }
    }
      

  2.   

    不是回车,是换行符,在输入完X数组后,按下回车会先产生回车符号,然后产生换行符,所以Y数组第一个变量为X数组的换行符。