How to implement compareTo method in Java
Submitted By:
javabuddy
Rating:





(
Rate It)
Share:
By Email
Visit
Description
CompareTo method is defined in Comparable interface in Java and used to implement natural ordering of object.Implementing and overriding compareTo is neither too easy but not too difficult as well , there are certain things we need to keep in mind e.g. compareTo must be consistent with equals method, not using subtraction for comparing two integers etc. This article explains correct way of implementing compareTo in Java.
Comments (2)
How do you calculate the area of a square in Java?




Posted by: AramHilgno on Friday, November 25, 2011
Sorry.Wrong question. Actually, the question is, how do I implement a method,such as compareTo, from the interface,Comparable, and use this method so that squares are compared according to their sides?
[url=http://www.rosettastoneoutletnow.com/]Rosetta Stone Online[/url]
How often will I fall when learning how to ride a bike?




Posted by: AramHilgno on Thursday, December 01, 2011
I've already fallen a handful of times while learning how to ride a bike at the age of 45. I only rode the bike once without falling. How often would you expect one would fall while learning how to ride a bike?
http://www.learnrosettastonenow.com/ How long before I get used to riding where I won't fall? A few days, a week, a month? Thx.
Add Your Rating