从键盘输入10个整数,存储到ArrayList集合中,然后遍历查找最大值输出结果。
import java.util.*;
public class A{
public static void main(String[] args){
List<Integer> list = new ArrayList<>();
Scanner sc = new Scanner(System.in);
for(int i = 0;i < 10;i++){
list.add(sc.nextInt());
}
sc.close();
int max = list.get(0);
for(int n : list){
if(n > max){
max = n;
}
}
System.out.println(max);
}
}