Firstly, agreeing with what Paul said.
You signature should be
rather than
This would map the type T that you have in your class to the type that Comparable takes.
Now, in order to avoid warnings, you have to do the following:
1) Change
to
Got through the tutorial at
http://java.sun.com/j2se/5/pdf/generics-tutorial.pdf to understand the above.
2) Change
to
This will again give you a warning of unchecked cast though
I dont know a way where you can avoid the above. Let me know if you get one.
But yeah you will avoid an unchecked call to compareTo with the above. So, atleast your code is safe at runtime.
Hope this helps,
nitesh