Java LinkedTransferQueue put() MethodThe 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 1Test it NowOutput: Elements in queue : [67, 109, 76, 876, 2] Example 2Test it NowOutput: John Harry Kristen Peter Example 3Test it NowOutput: 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) Next TopicJava LinkedTransferQueue |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India