📄 example13_2.java.bak
字号:
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("遍历链表用时:"+(time1-time2)+"毫秒");
time1=System.currentTimeMillis();
for(int i=0;i<list.size();i++)
{Student te=(Student)list.get(i);}
time2=System.currentTimeMillis();
System.out.println("遍历链表用时:"+(time1-time2)+"毫秒");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -