| title | Algorithm4 Java Solution 1.3.07 | ||
|---|---|---|---|
| date | 2019-07-04 05:47:10 +0800 | ||
| draft | false | ||
| tags |
|
||
| categories |
|
Add a method peek() to Stack that returns the most recently inserted item on the stack (without popping it).
public static void main(String[] args) {
_Stack<Integer> s = new _Stack<>();
s.push(1);
s.push(2);
s.push(3);
s.push(4);
assert s.peek() == 4; // pass
}