Java集合01----ArrayList的遍历方式及应用
时间:2014-06-20 10:22:41
收藏:0
阅读:240
Java集合01----ArrayList的遍历方式及应用
1.ArrayList的遍历方式
a.一般for循环(随机访问)
Integer value = null;
int size = list.size();
for (int i=0; i<size; i++) {
value = (Integer)list.get(i);
}
b.增强型for循环(for-each)
Integer value = null;
for (Integer intvalue:list) {
value = intvalue;
}
c.迭代器
Integer value = null;
Iterator iter = list.iterator();
while (iter.hasNext()) {
value = (Integer)iter.next();
}ArrayList三种遍历方式效率分析:
2.ArrayList的应用例子
未完,困死了,明天补齐~~~~~~~~~~~
评论(0)