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(); }