What exactly you mean by "Is it Okay". Is it legal? Yes. You can either use comparable by not specifying a comparator while instantiating or you can chose to use a comparator without/with your objects implementing comparable.
Originally posted by Sowmiya girish: Based the two replies - can we say that compareTo() can be used with or without implementing the comparable. Correct me if i am wrong...
Sure you can, but keep in mind that without saying that your class implements Comparable, you will not be able to pass a class instance to a method expecting a parameter that "is-a" Comparable. For example, the version of Collections.max that takes a Comparable:
Hope that helps!
Author, Spring Security 3 (the Book), Packt Publishing, 2010
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad: