📄 queuedemo.java
字号:
package chapter11;
import java.util.*;
public class QueueDemo {
public static void printQ(Queue queue){
while(queue.peek()!=null){
/*
* peek()方法!!!
*/
System.out.print(queue.remove()+" ");
/*
* remove()方法!!!
*/
}
}
public static void main(String args[]){
Queue<Integer> queue=new LinkedList<Integer>();
Random rand=new Random(47);
for(int i=0;i<10;i++){
queue.offer(rand.nextInt(i+10));
/*
* offer()方法!
*/
}
printQ(queue);
System.out.println();
Queue<Integer> queue2=new LinkedList<Integer>();
int a[]={1,2,3,4,5};
for(int j=0;j<5;j++){
queue2.add(j);
}
printQ(queue2);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -