PriorityBlockingQueue remainingCapacity() method in Java
The remainingCapacity method of PriorityBlockingQueue is used to check how much more elements can be inserted into this queue. But since the PriorityBlockingQueue is unbounded, this method always returns Integer.MAX_VALUE because a PriorityBlockingQueue is not capacity constrained.
public int remainingCapacity()
Return Value: Integer.MAX_VALUE always
Below programs illustrate remainingCapacity() method in PriorityBlockingQueue:
Queue: [1, 2, 3, 4] Remaining Capacity: 2147483647
Program 2: To demonstrate remainingCapacity() using String
Queue: [A Computer, Portal, Geeks, forGeeks] Remaining Capacity: 2147483647
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.