View RSS Feed

Algorithm and Data Structure

Java Queue

Rate this Entry
by , 02-19-2012 at 07:58 AM (687 Views)
Java Queue is also collection interface for holding the objects. Collections store or hold elements, before processing. Following operations are provided by Queues:

1. Insertion
2. Inspections
3. Extraction
4. (All) Other Collection operations

Queues are basically first in first order implements. They don’t depend on use order. Poll() and remove() methods are used to remove the elements present at head.

From queue’s tail, all elements gets added in case of FIFO queue. During different queues implementations, these rules might be different.

• An element is inserted by offer() method.
• The poll() or remove() methods are used for removal of the element. An exception is thrown by remove() method in case queue is empty. On the other hand, exception is not thrown by the poll() method. Just nulls is returned.
• The peek() and element() methods are used to return the elements. Head of queue is not removed by it.

Submit "Java Queue" to Facebook Submit "Java Queue" to Digg Submit "Java Queue" to Submit "Java Queue" to StumbleUpon Submit "Java Queue" to Google

Tags: java queue Add / Edit Tags