日期:2014-05-20 浏览次数:20667 次
public static int sum(List<Integer> list){ int sum=0; for(Iterator iter=list.iterator();iter.hasNext();){ int i=((Integer)iter.next()).intValue(); sum+=i; } return sum; }
------解决方案--------------------
11. public static int sum(List<Integer> intList){ 12. int sum = 0; 13. for (int i : intList) { 14. 15. sum+=i; 16. } 17. return sum; 18. }