如题所述
第1个回答 2017-03-30
主要功能代码如下:
package test;
import java.util.ArrayList;
import java.util.Scanner;
public class ScannerInput {
public static void main(String[] args) {
ArrayList<String> array = new ArrayList<String>();
Scanner scn = new Scanner(System.in);
String line;
String strings = "";
while (!"end".equals(line = scn.nextLine())) {
array.add(line);
strings += line + " ";
}
for (String str : array) {
System.out.println(str);
}
scn.close();
System.out.println(strings);
}
}本回答被网友采纳
package test;
import java.util.ArrayList;
import java.util.Scanner;
public class ScannerInput {
public static void main(String[] args) {
ArrayList<String> array = new ArrayList<String>();
Scanner scn = new Scanner(System.in);
String line;
String strings = "";
while (!"end".equals(line = scn.nextLine())) {
array.add(line);
strings += line + " ";
}
for (String str : array) {
System.out.println(str);
}
scn.close();
System.out.println(strings);
}
}本回答被网友采纳