Java ArrayBlockingQueue size() MethodThe size() method of Java ArrayBlockingQueue class returns the total number of elements in the ArrayBlockingQueue. Syntax:Parameters:NA Specified By:The size() method of ArrayBlockingQueue class is specified by:
Return Value:The size() method returns the total number of elements in this queue. Example 1Output: Total elements in the queue = 5 Elements are : 67 109 98 123 100 Example 2Output: Total Patients = 6 Megha Reema Supriya Anoop Sonia Tejashvi Patients recovered and discharged : [Megha, Reema, Supriya, Anoop] Patients left in the hospital = 2 Sonia Tejashvi Example 3Output: Exception in thread "main" java.lang.NullPointerException at java.util.concurrent.ArrayBlockingQueue.checkNotNull(ArrayBlockingQueue.java:150) at java.util.concurrent.ArrayBlockingQueue.offer(ArrayBlockingQueue.java:325) at java.util.AbstractQueue.add(AbstractQueue.java:95) at java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:312) at com.javaTpoint.ArrayBlockingQueueSizeExample3.main(ArrayBlockingQueueSizeExample3.java:10) |
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