首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

java作业题

2012-10-19 
求助:java作业题You are requested to output what you got from the system console.Input: A line of st

求助:java作业题
You are requested to output what you got from the system console.
 
Input: A line of string, until no inut is found! Example: 
This is the first line.
This is the second line.
...
This is the end.
 
Output: What you get from the console(keyboard)
This is the first line.
This is the second line.
...
This is the end.
 
Hints:
 
On getting input from the console, you can refer to the article. For reading a line from the console, here is a example:
 

Scanner s = new Scanner(System.in);
if (s.hasNextLine()) {
  String line = s.nextLine();
  ......
}


[解决办法]
1. 取得输入的行是不是空的,用String.isEmpty()判断,如果是空行,则退出while 循环
2. 把非空的行存入一个List
3. 输出List中的行

热点排行