This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
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