This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes doubtt in priority queue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubtt in priority queue" Watch "doubtt in priority queue" New topic
Author

doubtt in priority queue

rajeev jayappa
Greenhorn

Joined: Sep 15, 2008
Posts: 8
what is the difference between poll and peek method
i read the api but could not get the concept
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

They both returns the head of the queue, but poll() also removes the retrieved element.

Queue : 1,2,3,4
peek : 1 (queue:1,2,3,4)
peek : 1 (queue:1,2,3,4)
poll : 1 (queue:2,3,4)
peek : 2 (queue:2,3,4)


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubtt in priority queue