poll()
and remove()
method is used to remove head object of the Queue.empty()
. If Queue is empty then poll()
method will return null . While in similar case , remove()
method will throw NoSuchElementException . peek()
method retrieves but does not remove the head of the Queue. If queue is empty then peek()
method also returns null.