Home » Java ConcurrentLinkedQueue offer() Method

Java ConcurrentLinkedQueue offer() Method

by Online Tutorials Library

Java ConcurrentLinkedQueue offer() Method

The offer() method of ConcurrentLinkedQueue class is used to add the specified element at the tail of this queue.

Syntax:

Parameters:

The parameter ‘e’ is the element that is to be added in the queue.

Specified By:

The offer() method of ConcurrentLinkedQueue class is specified by:

offer in the interface Queue<E>.

Throws:

The offer() method throws NullPointerException – if the defined element(e) holds null value.

Return Value:

The offer() method returns true on the successful insertion, otherwise returns false.

Example 1

Test it Now

Output:

Queue : [12, 67, 45, 123]  

Example 2

Test it Now

Output:

Reema  Rahul  Rita  Ramesh  Gita  

Example 3

Test it Now

Output:

Reema       Panda     [email protected]  Geetanjali  Sharma    [email protected]  Vineet      Tanjea    [email protected]  Himanshu    Bhardwaj  [email protected]  

You may also like