type Comparable

Started by
1 comment, last by Illco 18 years, 4 months ago
i do not understand what the type comparable is for or what it does actually i dont understand anything about it i have looked at the api but not much info please help
Advertisement
What language are you talking about, and which API are you referring to?
I presume it is Java. First of all it is not a type but an interface. Second, if you don't know what it is for don't use it and don't bother.

It is for specifying a generic interface for comparable objects, such that any algorithms implemented for comparable objects can be applied to all their specific instances.

For example you may write a sorter which sorts any object that implements the comparable interface. This way you can sort any objects (even those not known at writing-time) such as a Date-class, Integers, etc. Nice.

Illco

This topic is closed to new replies.

Advertisement