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