Pages

Oct 19, 2018

Difference between Comparator and Comparable in Java


Though both Comparator and Comparable are interfaces and used to implement comparison logic between two instances of class, need to arrange them in order during sorting process; but there are subtle difference between them, which we will see in this article. Comparator can define custom ordering e.g. sorting same object with different condition but Comparable is usually used to define natural order e.g. numeric in numbers and alphabetic in String.






http://feeds.dzone.com/~r/dzone/frontpage/~3/oc6YcDBG-fA/difference_between_comparator_and_comparable_in_j_2.html

QuickBooks Self-Employed

Bigger tax refunds. Better organization. Manage your deductions with QuickBooks Self-Employed .