HomeNewsTech NewsComparable vs Comparator

Comparable vs Comparator

Comparable is an interface that an object can implement to compare itself with other object. If the return value is negative, that means it is less than the input object. If the return value is 0, that means it is equals to the input object, etc. Comparator is an interface that an object can implement to compare with TWO other objects. If the return value is negative, that means object one is less than object two. If the return value is 0, that means object one is equals to object tow, etc. We can use utility method in Collections class to do sorting with a comparator. Share Link:
Bookmark Google Yahoo MyWeb Del.icio.us Digg Facebook Myspace Reddit Ma.gnolia Technorati Stumble Upon

Polls

What's your favourite smartphone OS?