Java PriorityQueue clear() methodThe clear() method of PriorityQueue class Removes all the elements from this priority queue. After calling this method, the queue will be empty. SyntaxParameterNA Specified ByThe clear() method of class PriorityQueue is specified by clear() method in interface Collection<E>. OverrideThe clear() method of class PriorityQueue overrides the clear() method of class AbstractQueue<E>. Example 1Test it NowOutput: Course : [C, C++, Java, Python] After clearing the queue : [] Example 2Test it NowOutput: 1 Roll No = 2 Name = ravi Course = C Age = 21 2 Roll No = 1 Name = Geetanjali Course = Java Age = 21 3 Roll No = 3 Name = HimanshuBhardwaj Course = C++ Age = 21 After clearing the queue : []
Next TopicJava PriorityQueue
|