What you've done here is found one of the pitfalls of the now broken Comparable interface. This interface is broken because of 'generics by type erasure', which is the underlying flaw.
How you might ask? interface Comparable should have been interface Comparable<T>{T compareTo(T t);} (actually, the method *should* declare to throw NullPointerException, which is the optimal (but not ideal) workaround to the existance of 'null', which is a language design flaw). So why wasn't it done like that? Because it would break existing clients, so instead, we have a very broken interface, which is intrinsic to a very broken collections API (in many other ways).
What can you do about it? Rewrite collections (as I have done partially), or not use
Java - it's that simple (I say this because perservering with the compile-time warning fits the category of "not use Java" afaic). At some point, you have to concede to the brokenness; acknowledging it is important in making informed decisions. Acknowledging it is often misconceived as cynicism or what have you, but that's just the internet
Here's something I wrote that may be of interest:
http://qa.jtiger.org/GetQAndA.action?qids=70&showAnswers=true Edit:
Gah! I just reread my post.
"should have been interface Comparable<T extends Comparable>{int compareTo(T t);}" is what I meant - sorry for any confusion.
[ July 08, 2005: Message edited by: Tony Morris ]