Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Reads an item at the top of the stack, without removing it */
- public Data peek() {
- if (isEmpty()) { // 1
- throw new NoSuchElementException("Stack is empty!"); // 1
- }
- return top.data; // 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement