title: Java Point2D and Comparable
body: <p>I'm making a TreeSet of Point2D.Float type, creating it with a custom Comparable class that implements compare() of Point2D type. However, on calling "contains" on the TreeSet, I get a classcast error: <code>java.lang.ClassCastException: java.awt.geom.Point2D$Float cannot be cast to java.lang.Comparable</code></p>
  
  <p>The set is created as so:</p>
  
  <pre><code>private CoordinateComparator coordCompare;
  public TreeSet&lt;Point2D.Float&gt; coordSet = new TreeSet&lt;Point2D.Float&gt;(coordCompare);
  </code></pre>
  
  <p>Here is my compare class:</p>
  
  <pre><code> public class CoordinateComparator implements Comparator&lt;Point2D.Float&gt; {
   public CoordinateComparator() {}
  
   @Override
   public int compare(Point2D.Float p1, Point2D.Float p2) {
          if (p1.getX() &lt; p2.getX()) 
           return -1;
          if (p1.getX() &gt; p2.getX())
           return 1;
          if (p1.getY() &lt; p2.getY())
           return -1;
          if (p1.getY() &gt; p2.getY())
           return 1;
          return 0;
   }
  }
  </code></pre>
  
  <p>Any ideas on what's going wrong? I've been stuck here for hours trying to debug it to no avail. Thanks.</p>