The Java.util.PriorityQueue.size() method is used to get the size of the PriorityQueue or the number of elements present in the PriorityQueue.
Parameters: This method does not takes any parameter.
Return Value: The method returns the size or the number of elements present in the PriorityQueue.
Below programs illustrate the Java.util.PriorityQueue.size() method:
PriorityQueue: [For, Geeks, To, Welcome, Geeks] The size of the queue is: 5
PriorityQueue: [5, 10, 18, 20, 15, 30] The size of the queue is: 6
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.