Java list?????????????????
???????????? ???????[ 2014/11/21 11:33:14 ] ????????Java ??????? ????????
??????c/c++???????java????????java????list????????????????????????????????????????????????ArrayList?в???1????????????????ArrayList??????????????????????????????????£?
package com.hisense.tiger.list;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListTest {
public static void main(String[] args)
{
List<String> list = new ArrayList<String>();
long t1??t2;
for(int j = 0; j < 10000000; j++)
{
list.add("aaaaaa" + j);
}
System.out.println("List first visit method:");
t1=System.currentTimeMillis();
for(String tmp:list)
{
//System.out.println(tmp);
}
t2=System.currentTimeMillis();
System.out.println("Run Time:" + (t2 -t1) + "(ms)");
System.out.println("List second visit method:");
t1=System.currentTimeMillis();
for(int i = 0; i < list.size(); i++)
{
list.get(i);
//System.out.println(list.get(i));
}
t2=System.currentTimeMillis();
System.out.println("Run Time:" + (t2 -t1) + "(ms)");
System.out.println("List Third visit method:");
Iterator<String> iter = list.iterator();
t1=System.currentTimeMillis();
while(iter.hasNext())
{
iter.next();
//System.out.println(iter.next());
}
t2=System.currentTimeMillis();
System.out.println("Run Time:" + (t2 -t1) + "(ms)");
System.out.println("Finished!!!!!!!!");
}
}
?????????????????£?
????List first visit method:
????Run Time:170(ms)
????List second visit method:
????Run Time:10(ms)
????List Third visit method:
????Run Time:34(ms)
????Finished!!!!!!!!
????????????????????????????java??????????????????????????????????У????????????size???б?????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11