title: How do we delete an object from Priority Queue of user defined data type
body: <pre><code>class Solution{
  static class pair implements Comparable&lt;pair&gt; {
  
      int a, b;
  
      @Override
      public int compareTo(pair o) {
          return (a-o.a);
      }
  
      public pair(int a, int b) {
  
          this.a = a;
          this.b = b;
  
      }
  
  }
   public static void main(String[] args) {
          PriorityQueue&lt;pair&gt; min = new PriorityQueue&lt;&gt;();
          min.add(new pair(9,0));
          min.add(new pair(2,4));
          pair p=new pair(2, 4);
          min.remove(p);
          System.out.println(min.size());
         
         
         
  
      }
  
  
  }
  </code></pre>
  <p>how do i delete an pair type element from priority queue. This .remove() method does not seem to work for user defined type classes.</p>