Java 数组遍历

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

 

posted @ 2017-05-24 16:20  羊羊羊&#128017;  Views(135)  Comments(0Edit  收藏  举报