Removes a single instance of the specified element from this queue, if it is present.
This method and the last method are not overloaded because of different return types.
package com.logicbig.example.priorityqueue;
import java.util.PriorityQueue;
public class RemoveExample2 {
public static void main(String... args) {
PriorityQueue<String> pq = new PriorityQueue<>();
pq.add("one");
pq.add("two");
pq.add("one");
System.out.println(pq);
pq.remove("one");
System.out.println(pq);
}
}
Output
[one, two, one]
[one, two]