Java PriorityQueue remove() MethodThe remove() method of PriorityQueue class removes a single instance of the specified element from this queue, only if it is present. SyntaxParametero - It is the element to be eliminated from this queue. Specified ByThe remove() method of the PriorityQueue class is specified by remove() method in interface Collection<E>. OverrideThe remove() method of the PriorityQueue class is override by remove() method in class AbstractCollection<E>. Return ValueThe remove() method returns true if this queue is changed after the call. Example 1Output: Queue before using remove() method : Adam Ahana Chris Rafiq Amir Queue after using remove() method :true Adam Ahana Amir Rafiq Example 2Output: Queue before using remove() method : 45 67 56 98 73 Queue after using remove() method :false 45 67 56 98 73 Example 3Output: Patients are : [Amar, Mukta, Aloke] Patients left : [Amar, Aloke] Example 4Output: Elements in queue = [1, 2, 3] Element removed = 1 Elements left in queue = [2, 3] Element removed = 2 Elements left in queue = [3] Next TopicJava-priorityqueue-size-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