Sunday, 29 January 2017

poll(), peek() and remove() Method in the Queue

E java.util.PriorityQueue.poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.

Specified by: poll() in Queue
Returns: the head of this queue, or null if this queue is empty


E java.util.PriorityQueue.peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Specified by: peek() in Queue
Returns: the head of this queue, or null if this queue is empty

E java.util.AbstractQueue.remove()
Retrieves and removes the head of this queue. This method differs from poll only in that it throws an exception if this queue is empty.

Specified by: remove() in Queue
Returns: the head of this queue
Throws: NoSuchElementException - if this queue is empty




No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...