compare


Description:

public int compare (Comparable? other)

Compares the two objects, returning <code class="literal">-1</code> if this is "less than" other by some metric, <code class="literal">0</code> if they're equal, or <code class="literal">1</code > if this is "greater than" other.

null values are handled gracefully, with <code class="literal">0</code> returned if both this and other are null, <code class="literal">-1 </code> if this is null and <code class="literal">1< /code> if other is null.

The other object must be of the same type as this, or of a type derived from this's type.

Parameters:

this

a Comparable, or null

other

another Comparable of the same type, or null

Returns:

true on success, false otherwise