?? 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 + -