ArrayList<Integer> al = new ArrayList<Integer>(); //数组定义 //遍历数组: int sum = 0; Iterator<Integer> itr = al.iterator(); while(itr.hasNext()){ Integer intObj = (Integer)itr.next(); sum += intObj.intValue(); }
时间: 2024-11-05 21:12:27
ArrayList<Integer> al = new ArrayList<Integer>(); //数组定义 //遍历数组: int sum = 0; Iterator<Integer> itr = al.iterator(); while(itr.hasNext()){ Integer intObj = (Integer)itr.next(); sum += intObj.intValue(); }