example13_2.java
来自「不错的教程 适合中高级人员的使用」· Java 代码 · 共 29 行
JAVA
29 行
import java.util.*;
class Student
{String name ;int number;
Student(String name,int number)
{this.name=name;this.number=number;
}
}
public class Example13_2
{public static void main(String args[])
{ List list=new LinkedList();
for(int k=1;k<=22222;k++)
{list.add(new Student("I am "+k,k));}
Iterator iter=list.iterator();
long time1=System.currentTimeMillis();
while(iter.hasNext())
{ Student te=(Student)iter.next();
//System.out.println(te.name+" "+te.number+" "+te.score);
}
long time2=System.currentTimeMillis();
System.out.println("遍历链表用时:"+(time2-time1)+"毫秒");
time1=System.currentTimeMillis();
for(int i=0;i<list.size();i++)
{Student te=(Student)list.get(i);}
time2=System.currentTimeMillis();
System.out.println("遍历链表用时:"+(time2-time1)+"毫秒");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?