public static void main(String[] args) {
Deque<Integer> q1=new LinkedList();
q1.offer(1);
q1.offer(2);
q1.offer(3);
q1.offer(4);
q1.offer(5);
System.out.println(q1.poll());
System.out.println(q1.pop());
System.out.println(q1.peek());
q1.push(6);
System.out.println(q1.poll());
}
结果:
1
2
3
6
队列是尾进头出,队列的头对应栈的顶