title: Attempting to override existing comparator for PriorityQueue in Java
body: <p>So I am trying to implement Dijkstra's algorithm using the priority queue data structure in java. The only thing I need to modify is the comparable operator as java cannot compare two variables of type Adjacency (user defined). I want to use the PriorityQueue data structure and all I want to do is to modify the compareTo operator so that it can compare two variables of type Adjacency. As of now the error I get is "The type PriorityQueue must implement the inherited abstract method Comparable.compareTo(Adjacency)". When I try adding the "@override" tag above the compareTo operator, I get the error "override cannot be resolved to a type".</p>
  
  <pre><code>public class Adjacency {
    public int vertex;
    public double weight;
    public Adjacency(int v, double w) {
      vertex = v;
      weight = w;
    }
  }
  
  public class PriorityQueue&lt;T extends PriorityQueue&lt;T&gt;&gt; implements Comparable&lt;Adjacency&gt; {
  
  
      public int compareTo(Adjacency o1, Adjacency o2) {
          return Double.compare(o1.weight, o2.weight);
  
  
      }
  
  }
  </code></pre>
  
  <p>EDIT: Here is the Hello class which implements Comparator. The mistake I was making is by using Comparable because you can only compare this and another variable and cannot pass two separate variables to the class. Implementing Comparator solves that problem.</p>
  
  <p>import java.util.*;</p>
  
  <pre><code>public class Hello implements Comparator&lt;Adjacency&gt;{
  
      @Override
      public int compare(Adjacency o1, Adjacency o2) {
         return Double.compare(o1.weight, o2.weight);
  
        }
  
  }
  </code></pre>