previous | start | next

## The `Comparable` Interface Type

- `Collections` has static `sort` method:

      ArrayList a = . . .

      Collections.sort(a);

- Objects in list must implement the `Comparable` interface type

      public interface Comparable

      {

         int compareTo(Object other);

      }

- `object1.compareTo(object2)` returns
- - Negative number if `object1` less than `object2`
  - 0 if objects identical
  - Positive number if `object1` greater than `object2`

previous | start | next