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 1Output: Course : [C, C++, Java, Python] After clearing the queue : [] Example 2Output: 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-comparator-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India