Java PriorityQueue size() MethodLast Updated : 17 Mar 2025 The size() method of PriorityQueue class returns the number of elements contained by this collection. If there are more than Integer.MAX_VALUE elements in this collection, the method returns Integer.MAX_VALUE. SyntaxParameterNA Specified ByThe size() method of PriorityQueue class is specified by:
Return ValueThe size() method returns the count of elements contained by this collection. Example 1Output: First PriorityQueueis : [123, 375, 258, 682, 842, 654, 556, 998] The size of first queue is: 8 Second PriorityQueueis : [Gaurav, Hitesh] The size of second queue is: 2 Example 2Output: The strength of Btech_Cse is 5 Example 3Output: 2 elements = [Himanshu, Rinku] 0 elements = [] Next TopicJava-priorityqueue-spliterator-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India