title: Java priority queues and comparable interface
body: <p>I've just been learning about priority queues and thought I'd try how it behaves with comparable interface.</p>
  
  <p><strong>Code Snippet:</strong></p>
  
  <pre><code>import java.util.PriorityQueue;
  
  class kinga implements Comparable&lt;Double&gt; {
      double time=909.909;
      double d;
  
      public kinga(double a) {  
          this.d=a;
      }
  
      public int compareTo(Double d) {
          return Double.compare(d, time);
      }
  
      public static void main(String arg[]) {
          PriorityQueue&lt;kinga&gt; r=new PriorityQueue&lt;kinga&gt;();
  
          r.add( new kinga(4545.45));
          r.add( new kinga(45.4));
          r.add( new kinga(1235.45));
  
          System.out.println(r.poll()+" "+r.poll()+" "+r.poll());
      }
  }
  </code></pre>
  
  <p>It compiles but gives me Exception in <strong>thread "main"</strong> <code>java.lang.ClassCastException: kinga cannot be cast to java.lang.Double</code>.</p>
  
  <p>What is wrong here. Can somebody tell me how comparable and priority queues work?</p>