读书人

java作业题

发布时间: 2012-10-19 16:53:36 作者: rapoo

求助: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中的行

读书人网 >J2SE开发

热点推荐