1 public class Test01{
2 public static void main(String[] args) {
3 ArrayList<Integer> list=new ArrayList<Integer>();
4 System.out.println("请输入数据:");
5 while(true){
6 Scanner sc=new Scanner(System.in);
7 int num=sc.nextInt();
8 if(num!=0){
9 list.add(num);
10 }else{
11 System.out.println("over");
12 break;
13
14 }
15
16 }
17 Iterator<Integer> it=list.iterator();
18 while(it.hasNext()){
19 System.out.print(it.next());
20 }
21
22 Integer[] i=new Integer[list.size()];
23 list.toArray(i);
24
25 Arrays.sort(i);
26 System.out.println("the max is: "+i[i.length-1]);
27
28
29
30 }
31 }