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 }
![](/i/l/?n=23&i=blog/2504026/202302/2504026-20230201210252657-216758104.png)
标签:Java,Scanner,list,System,sc,input,输入 From: https://www.cnblogs.com/linxuannihao/p/17084138.html