增强for 可以用于ArrayList

 

ArrayList<Integer> list=null;

for(int i : list){
    sum+=i;
}
原文地址:https://www.cnblogs.com/kakaisgood/p/6371357.html