这两个程序为什么会有区别..?

ShingU 2004-04-16 08:31:06
//程序1
import java.io.*;

class Test
{
public static void main(String [] args) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

System.err.println("Type in some lines.");

while (true)
{
if (in.readLine().length() == 0)
break;

System.out.println("The line \"" + in.readLine() + "\"");
}

System.out.println("The end.");
}
}

//程序2
import java.io.*;

class Test
{
public static void main(String [] args) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

System.err.println("Type some lines.");

while (true)
{
String str = din.readLine().trim();

if (str.length() == 0)
break;

System.out.println("The line \"" + str + "\"");
}

System.out.println("The end.");
}
}
...全文
24 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
升烟张诚 2004-04-16
  • 打赏
  • 举报
回复
第一个程序不是有两个readline吗,就是输入两句,只输出后一句
新来的萌新 2004-04-16
  • 打赏
  • 举报
回复
大兄弟!提问可不可以跟点分!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧