How to implement CompareTo method in Java
Advertisements
| Top Tutorials | New Tutorials | Submit | Login | Register |
Tutorial Detail
How to implement CompareTo method in Java
CompareTo method is defined in Comparable interface in Java and used to implement natural ordering of object.Implementing and overriding compareTo ishttp://javarevisited.blogspot.com/2011/11/how-to-override-compareto-method-in.html
Total Hits: 2927
Total Votes: 13 votes
Category: JAVA/Core JAVA
Submitted on: 2011-11-15 15:11:31
Submitted By: Javin Paul
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. More detail...Rating Detail
| Stars | Percentage | Total Vote |
|---|---|---|
![]() |
![]() ![]() 15.38% |
2 |
![]() ![]() |
![]() ![]() 15.38% |
2 |
![]() ![]() ![]() |
![]() ![]() 23.08% |
3 |
![]() ![]() ![]() ![]() |
![]() ![]() 15.38% |
2 |
![]() ![]() ![]() ![]() ![]() |
![]() ![]() 15.38% |
2 |





15.38%

15.38%

23.08%

15.38%

15.38%