Tuesday, 3 November 2015

What is the difference between peek(), poll() and remove() method of the Queue interface?

Difference between peek(), poll() and remove() method of the Queue interface


poll()
remove()
peek()


Action

Remove the head object of Queue.

Remove the head object of Queue.

Retrieves but does not remove the head of the Queue.

Queue is null.

poll() method will return null.

remove() method will throw NoSuchElementException.

poll() method will return null.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...