You need to understand difference between Comparable and Comparator.
Comparable implementations provide a natural ordering for a class, which allows objects of that class to be sorted automatically.
Comparator is an object that encapsulates an ordering. You will use Comparator when you want to sort some objects in an order other than their natural ordering or when you want to sort some objects that don't implement Comparable.
Oops , yes I interpreted the problem incorrectly, my apologies Here is the sample program that will work. I hope I am correct this time.
I am running it in eclipse and "bin" is where my .class files are.