Each Node
contains:
val
) of type Object
.next
).head
: Points to the front of the queue.tail
: Points to the end of the queue.enqueue(Object v)
Adds a new element to the end of the queue.
Updates the tail
reference.
dequeue()
Removes and returns the front element of the queue.
Updates the head
reference.
Throws a RuntimeException
if the queue is empty.
peek()
Returns the front element without removing it.
Throws a RuntimeException
if the queue is empty.
isEmpty()
Returns true
if the queue is empty, otherwise false
.
The Queue
class is used in src/expensetracker/Main.java
to manage recent actions performed by the user.