Java PriorityQueue size() MethodThe 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 1Test it NowOutput: 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 2Test it NowOutput: The strength of Btech_Cse is 5 Example 3Test it NowOutput: 2 elements = [Himanshu, Rinku] 0 elements = []
Next TopicJava PriorityQueue
|