java 如何輸入多行,當碰到空行中止輸入

public class a_7 { public static void main(String args[]) {code

Scanner reader = new Scanner(System.in);
 
 String a[]=new String[10];
 
 String line;
 
 List <String> list = new ArrayList<String>();
 
 while(!(line =reader.nextLine()).equals("")) {
 
	 list.add(line);
	 
 }
 
 System.out.println("io");
 
 Iterator it = list.iterator();
 
 while(it.hasNext()) {
 
	 System.out.println(it.next());
	 
 }

} }it

相關文章
相關標籤/搜索