• Advertisement
Sign in to follow this  

type Comparable

This topic is 4467 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
What language are you talking about, and which API are you referring to?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement