Java LinkedTransferQueue size() methodThe size() method of LinkedTransferQueue class returns the returns the total count of the elements present in the queue. Syntax:Specified By:The size() method of LinkedTransferQueue class is specified by:
Return:This method returns the number of elements in this queue. Example 1Test it NowOutput: The size of queue : 4 Queue : [34, 22, 26, 215] Example 2Test it NowOutput: Total Patients = 6 1.John 2.Harry 3.Peter 4.Marry 5.Jack 6.Lucene Patients recovered and discharged : [John, Harry, Peter, Marry] Patients left in the hospital = 2 1.Jack 2.Lucene 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.add(Unknown Source) at tests.LinkedTransferQueueSizeExample3.main(LinkedTransferQueueSizeExample3.java:5) 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