Comparable

Comparable

Quick overview of the Comparable interface. The idea is that, for things that implement Comparable, there is an ordering of those elements; we can say 'bee' comes before 'eel' by alphabetical ordering for Strings, for instance. And for Integers, 17 comes before 18, etc.

It's defined as interface with one method:
  public interface Comparable
  {
    public int compareTo(T t);
  }

When comparing 2 things (compare a to b via a.compareTo(b) ) compareTo should return -1 if a<b, return 1 if a>b, and return 0 if the two are equivalent. Which element is greater than the other depends on what you're looking at; for Strings, it's alphabetical ordering, for numbers it's numerical ordering.