82
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
Output:
Queue : [12, 67, 45, 123]
Example 2
Output:
Reema Rahul Rita Ramesh Gita
Example 3
Output:
Reema Panda [email protected] Geetanjali Sharma [email protected] Vineet Tanjea [email protected] Himanshu Bhardwaj [email protected]
Next TopicJava ConcurrentLinkedQueue