stack peek()和stack pop()

100 阅读1分钟

stack.peek()和stack.pop();

相同点:大家都返回栈顶的值。

不同点:peek 不改变栈的值(不删除栈顶的值),pop会把栈顶的值删除。