ArrayList<Integer> list=null; for(int i : list){ sum+=i; } 转载于:https://www.cnblogs.com/kakaisgood/p/6371357.html