ft,又遇到怪问题了 \r,你可以试着把\r转换为\\r,应该就能显示出来,那样能感觉只管点(只是自我感觉,没有实验,建议你做一下实验) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 多出来的一个字符确实是回车原因如下:在你输入完 第一次 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]); }} 不是回车,是换行符,在输入完X数组后,按下回车会先产生回车符号,然后产生换行符,所以Y数组第一个变量为X数组的换行符。 JTree 缩进去除 测试关闭阻塞中的线程 jvm线程调度! JCreator 运行 java程序 窗口自动关闭 请教大侠在Struts中的MVC2设计模式中的二个小问题,能不能给个标准的答案?谢谢! Jdk 1.5和Jdk 5.0有什么区别啊? 寫了一個簡單的增加工資的程序,不知道錯在哪裡,幫忙看看,指正! 现在世面上有没有集收发邮件,发短信,日历,日记,便签,等功能于一身的软件? 这个问题是怎么回事啊 BufferedReader的readLine 什么时候返回null啊? 多态性 菜鸟问题:矩阵乘法的这一句是不是这样写?
在你输入完 第一次 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]);
}
}