声明:
Stackstack = new Stack<>();
压栈
stack.push('p');
stack.push('r');
stack.push('c');
访问栈顶元素(不删除)
System.out.println(stack.peek());
整个栈内元素弹栈
while (!stack.empty()){
System.out.println(stack.pop());
}
Queue类型
public interface Queueextends Collection
队列为接口不能实例化
声明
Queuequeue = new LinkedBlockingQueue<>();
入队
queue.offer(100);
queue.offer(200);
访问第一个队首元素
System.out.println(queue.peek());
完全出队
while (!queue.isEmpty()){
System.out.println(queue.poll());
}



