队列Queue
@Test
public void testQueue(){int count =5;
Queue<String> q=new LinkedList<String>();
q.offer("zs");
q.offer("ls");
q.offer("ww");
q.offer("zl");
q.offer("qq");
q.offer("you");
q.offer("you1");
q.offer("you2");
q.offer("you3");
q.offer("you4");
for(;count>0;count--){
System.out.println(q.poll()+"-------秒杀成功");
}
System.out.println(q.peek()+"-------没抢上");
while(q.size()>0){
System.out.println(q.poll()+"-------没抢上");
}
}
---------------输出内容如下:
zs-------秒杀成功
ls-------秒杀成功
ww-------秒杀成功
zl-------秒杀成功
qq-------秒杀成功
you-------没抢上
you-------没抢上
you1-------没抢上
you2-------没抢上
you3-------没抢上
you4-------没抢上