1 public static void main(String[] args) { 2 Scanner sc = new Scanner(System.in); 3 List<Integer> list = new ArrayList<>(); 4 String input = sc.next(); 5 6 while (!input.equals("exit")) { 7 list.add(Integer.parseInt(input)); 8 input = sc.next(); 9 } 10 System.out.println(list.toString()); 11 }
标签:Java,Scanner,list,System,sc,input,输入 From: https://www.cnblogs.com/linxuannihao/p/17084138.html