rambless
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextLine()) { // 注意 while 处理多个 case String str = in.nextLine(); parse(str); } } private static void parse(String str) { List<String> list = new ArrayList<>(); String temp = ""; for(int i=0; i<str.length(); i++) { //如果是空格 if(str.charAt(i)==' ') { list.add(temp); temp = ""; } else if(str.charAt(i)=='"') { int j = i+1; while(j<str.length()) { if(str.charAt(j)=='"') { break; } j++; } list.add(str.substring(i+1, j)); i = j + 1; } else { temp += str.substring(i, i+1); } } if(temp.length()>0) { list.add(temp); } System.out.println(list.size()); for(String s: list) { System.out.println(s); } } }