Javatpoint Logo
Javatpoint Logo

Java LinkedTransferQueue put() Method

The put() method of LinkedTransferQueue adds the defined element at the tail of this queue. It waits till the space becomes available if queue is full.

Syntax:

Parameters:

e - This is the element to be added.

Specified By:

The put() method of LinkedTransferQueue class is specified by put() method in interface BlockingQueue.

Return:

NA

Throws:

NullPointerException - This exception will throw if the specified element is null.

Example 1

Test it Now

Output:

Elements in queue : [67, 109, 76, 876, 2]

Example 2

Test it Now

Output:

John
Harry
Kristen
Peter

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.concurrent.LinkedTransferQueue.xfer(Unknown Source)
	at java.base/java.util.concurrent.LinkedTransferQueue.put(Unknown Source)
	at tests.LinkedTransferQueuePutExample3.main(LinkedTransferQueuePutExample3.java:11)






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA