How to override compareTo method in Java Example Tutorial

Sabtu, 01 Februari 2014

compareTo in Java is in the same league of equals() and hashcode() and used to implement natural order of object, compareTo is slightly different to compare() method of Comparator interface which is used to implement custom sorting order. I have seen during java interviews that many Java programmers not able to correctly write or implement equals(), hashCode() and compareTo() method for common business objects like Order or Employee. Simple reason behind this is that they either not understand the concept well enough or doesn't write this stuff at all. I will try to fill that gap in this Java tutorial and will see What is compareTo() method in java, how to write compareTo in Java and things to remember while implementing compareTo in Java.
Read more »

Related Posts by Categories

0 komentar:

Posting Komentar

Copyright © 2010 Computer Tips and Trick | Powered By Blogger