# Comparable

public interface **Comparable**

|---|---|---|
| Known Indirect Subclasses [AbstractChronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/AbstractChronology.html), [AccessMode](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/AccessMode.html), [AclEntryFlag](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryFlag.html), [AclEntryPermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryPermission.html), [AclEntryType](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryType.html), [Authenticator.RequestorType](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Authenticator.RequestorType.html), [Boolean](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Boolean.html), [Byte](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Byte.html), [ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html), [CRLReason](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/CRLReason.html), [Calendar](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Calendar.html), [CertPathValidatorException.BasicReason](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/CertPathValidatorException.BasicReason.html), [CharBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/CharBuffer.html), [Character](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Character.html), [Character.UnicodeScript](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Character.UnicodeScript.html), and [80 others.](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable#) |---|---| | [AbstractChronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/AbstractChronology.html) | An abstract implementation of a calendar system, used to organize and identify dates. | | [AccessMode](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/AccessMode.html) | Defines access modes used to test the accessibility of a file. | | [AclEntryFlag](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryFlag.html) | Defines the flags for used by the flags component of an ACL `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntry.html`. | | [AclEntryPermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryPermission.html) | Defines the permissions for use with the permissions component of an ACL `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntry.html`. | | [AclEntryType](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/AclEntryType.html) | A typesafe enumeration of the access control entry types. | | [Authenticator.RequestorType](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Authenticator.RequestorType.html) | The type of the entity requesting authentication. | | [Boolean](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Boolean.html) | The Boolean class wraps a value of the primitive type `boolean` in an object. | | [Byte](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Byte.html) | The `Byte` class wraps a value of primitive type `byte` in an object. | | [ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) | A byte buffer. | | [CRLReason](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/CRLReason.html) | The CRLReason enumeration specifies the reason that a certificate is revoked, as defined in [RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile](http://www.ietf.org/rfc/rfc3280.txt). | | [Calendar](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Calendar.html) | The `Calendar` class is an abstract class that provides methods for converting between a specific instant in time and a set of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Calendar.html#fields` such as `YEAR`, `MONTH`, `DAY_OF_MONTH`, `HOUR`, and so on, and for manipulating the calendar fields, such as getting the date of the next week. | | [CertPathValidatorException.BasicReason](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/CertPathValidatorException.BasicReason.html) | The BasicReason enumerates the potential reasons that a certification path of any type may be invalid. | | [CharBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/CharBuffer.html) | A char buffer. | | [Character](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Character.html) | The `Character` class wraps a value of the primitive type `char` in an object. | | [Character.UnicodeScript](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Character.UnicodeScript.html) | A family of character subsets representing the character scripts defined in the [*Unicode Standard Annex #24: Script Names*](http://www.unicode.org/reports/tr24/). | | [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) | A named mapping between sequences of sixteen-bit Unicode [code units](https://developers.google.com/j2objc/javadoc/jre/reference/lang/Character.html#unicode) and sequences of bytes. | | [ChronoField](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoField.html) | A standard set of fields. | | [ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html) | A date without time-of-day or time-zone in an arbitrary chronology, intended for advanced globalization use cases. | | [ChronoLocalDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDateTime.html)\<D extends [ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html)\> | A date-time without a time-zone in an arbitrary chronology, intended for advanced globalization use cases. | | [ChronoUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html) | A standard set of date periods units. | | [ChronoZonedDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoZonedDateTime.html)\<D extends [ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html)\> | A date-time with a time-zone in an arbitrary chronology, intended for advanced globalization use cases. | | [Chronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/Chronology.html) | A calendar system, used to organize and identify dates. | | [ClientInfoStatus](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/ClientInfoStatus.html) | Enumeration for status of the reason that a property could not be set via a call to `Connection.setClientInfo` | | [CollationKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html) | A `CollationKey` represents a `String` under the rules of a specific `Collator` object. | | [Collector.Characteristics](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Collector.Characteristics.html) | Characteristics indicating properties of a `Collector`, which can be used to optimize reduction implementations. | | [CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html) | An enumeration of cryptographic primitives. | | [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html) | The class `Date` represents a specific instant in time, with millisecond precision. | | [DayOfWeek](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/DayOfWeek.html) | A day-of-week, such as 'Tuesday'. | | [Delayed](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Delayed.html) | A mix-in style interface for marking objects that should be acted upon after a given delay. | | [Double](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Double.html) | The `Double` class wraps a value of the primitive type `double` in an object. | | [DoubleBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/DoubleBuffer.html) | A double buffer. | | [Duration](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Duration.html) | A time-based amount of time, such as '34.5 seconds'. | | [ElementType](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/annotation/ElementType.html) | The constants of this enumerated type provide a simple classification of the syntactic locations where annotations may appear in a Java program. | | [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> | This is the common base class of all Java language enumeration types. | | [File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) | An abstract representation of file and directory pathnames. | | [FileVisitOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/FileVisitOption.html) | Defines the file tree traversal options. | | [FileVisitResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/FileVisitResult.html) | The result type of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/FileVisitor.html`. | | [Float](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Float.html) | The `Float` class wraps a value of primitive type `float` in an object. | | [FloatBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/FloatBuffer.html) | A float buffer. | | [FormatStyle](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/format/FormatStyle.html) | Enumeration of the style of a localized date, time or date-time formatter. | | [Formatter.BigDecimalLayoutForm](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.BigDecimalLayoutForm.html) | Enum for `BigDecimal` formatting. | | [GregorianCalendar](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/GregorianCalendar.html) | `GregorianCalendar` is a concrete subclass of `Calendar` and provides the standard calendar system used by most of the world. | | [Instant](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Instant.html) | An instantaneous point on the time-line. | | [IntBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/IntBuffer.html) | An int buffer. | | [Integer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Integer.html) | The `Integer` class wraps a value of the primitive type `int` in an object. | | [IsoChronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/IsoChronology.html) | The ISO calendar system. | | [IsoEra](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/IsoEra.html) | An era in the ISO calendar system. | | [KeyRep.Type](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyRep.Type.html) | Key type. | | [LinkOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/LinkOption.html) | Defines the options as to how symbolic links are handled. | | [LocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalDate.html) | A date without a time-zone in the ISO-8601 calendar system, such as `2007-12-03`. | | [LocalDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalDateTime.html) | A date-time without a time-zone in the ISO-8601 calendar system, such as `2007-12-03T10:15:30`. | | [LocalTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalTime.html) | A time without a time-zone in the ISO-8601 calendar system, such as `10:15:30`. | | [Locale.Category](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.Category.html) | Enum for locale categories. | | [Locale.FilteringMode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.FilteringMode.html) | This enum provides constants to select a filtering mode for locale matching. | | [Long](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Long.html) | The `Long` class wraps a value of the primitive type `long` in an object. | | [LongBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/LongBuffer.html) | A long buffer. | | [MappedByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/MappedByteBuffer.html) | A direct byte buffer whose content is a memory-mapped region of a file. | | [Month](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Month.html) | A month-of-year, such as 'July'. | | [MonthDay](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/MonthDay.html) | A month-day in the ISO-8601 calendar system, such as `--12-03`. | | [Normalizer.Form](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Normalizer.Form.html) | The normalization forms supported by the Normalizer. | | [NumericShaper.Range](https://developers.google.com/j2objc/javadoc/jre/reference/java/awt/font/NumericShaper.Range.html) | A `NumericShaper.Range` represents a Unicode range of a script having its own decimal digits. | | [ObjectStreamField](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html) | A description of a Serializable field from a Serializable class. | | [OffsetDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/OffsetDateTime.html) | A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as `2007-12-03T10:15:30+01:00`. | | [OffsetTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/OffsetTime.html) | A time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as `10:15:30+01:00`. | | [PKIXReason](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/PKIXReason.html) | The `PKIXReason` enumerates the potential PKIX-specific reasons that an X.509 certification path may be invalid according to the PKIX (RFC 3280) standard. | | [PKIXRevocationChecker.Option](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/PKIXRevocationChecker.Option.html) | Various revocation options that can be specified for the revocation checking mechanism. | | [Path](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/Path.html) | An object that may be used to locate a file in a file system. | | [PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html) | Defines the bits for use with the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFileAttributes.html#permissions()` attribute. | | [Proxy.Type](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Proxy.Type.html) | Represents the proxy type. | | [ResolverStyle](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/format/ResolverStyle.html) | Enumeration of different ways to resolve dates and times. | | [RetentionPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/annotation/RetentionPolicy.html) | Annotation retention policy. | | [RowIdLifetime](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/RowIdLifetime.html) | Enumeration for RowId life-time values. | | [RunnableScheduledFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableScheduledFuture.html)\<V\> | A `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledFuture.html` that is `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html`. | | [SSLEngineResult.HandshakeStatus](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLEngineResult.HandshakeStatus.html) | An `SSLEngineResult` enum describing the current handshaking state of this `SSLEngine`. | | [SSLEngineResult.Status](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLEngineResult.Status.html) | An `SSLEngineResult` enum describing the overall result of the `SSLEngine` operation. | | [ScheduledFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledFuture.html)\<V\> | A delayed result-bearing action that can be cancelled. | | [Short](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Short.html) | The `Short` class wraps a value of primitive type `short` in an object. | | [ShortBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ShortBuffer.html) | A short buffer. | | [SignStyle](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/format/SignStyle.html) | Enumeration of ways to handle the positive/negative sign. | | [StandardCopyOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/StandardCopyOption.html) | Defines the standard copy options. | | [StandardOpenOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/StandardOpenOption.html) | Defines the standard open options. | | [StandardProtocolFamily](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/StandardProtocolFamily.html) | Defines the standard families of communication protocols. | | [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | The `String` class represents character strings. | | [TextStyle](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/format/TextStyle.html) | Enumeration of the style of text formatting and parsing. | | [Time](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Time.html) | A thin wrapper around the `java.util.Date` class that allows the JDBC API to identify this as an SQL `TIME` value. | | [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) | A `TimeUnit` represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units. | | [Timestamp](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Timestamp.html) | A thin wrapper around `java.util.Date` that allows the JDBC API to identify this as an SQL `TIMESTAMP` value. | | [URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) | Represents a Uniform Resource Identifier (URI) reference. | | [UUID](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/UUID.html) | A class that represents an immutable universally unique identifier (UUID). | | [Year](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Year.html) | A year in the ISO-8601 calendar system, such as `2007`. | | [YearMonth](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/YearMonth.html) | A year-month in the ISO-8601 calendar system, such as `2007-12`. | | [ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html) | A time-zone offset from Greenwich/UTC, such as `+02:00`. | | [ZoneOffsetTransition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html) | A transition between two offsets caused by a discontinuity in the local time-line. | | [ZoneOffsetTransitionRule.TimeDefinition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransitionRule.TimeDefinition.html) | A definition of the way a local time can be converted to the actual transition date-time. | | [ZonedDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZonedDateTime.html) | A date-time with a time-zone in the ISO-8601 calendar system, such as `2007-12-03T10:15:30+01:00 Europe/Paris`. | |||

This interface imposes a total ordering on the objects of each class that
implements it. This ordering is referred to as the class's *natural ordering*, and the class's compareTo method is referred to as
its *natural comparison method*.


Lists (and arrays) of objects that implement this interface can be sorted
automatically by `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collections.html#sort(java.util.List<T>)` (and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Arrays.html#sort(java.lang.Object[])`). Objects that implement this
interface can be used as keys in a {@linkplain SortedMap sorted map} or as
elements in a {@linkplain SortedSet sorted set}, without the need to
specify a {@linkplain Comparator comparator}.


The natural ordering for a class C is said to be *consistent with equals* if and only if e1.compareTo(e2) == 0 has
the same boolean value as e1.equals(e2) for every
e1 and e2 of class C. Note that null
is not an instance of any class, and e.compareTo(null) should
throw a NullPointerException even though e.equals(null)
returns false.


It is strongly recommended (though not required) that natural orderings be
consistent with equals. This is so because sorted sets (and sorted maps)
without explicit comparators behave "strangely" when they are used with
elements (or keys) whose natural ordering is inconsistent with equals. In
particular, such a sorted set (or sorted map) violates the general contract
for set (or map), which is defined in terms of the equals
method.


For example, if one adds two keys a and b such that
`(!a.equals(b) && a.compareTo(b) == 0)` to a sorted
set that does not use an explicit comparator, the second add
operation returns false (and the size of the sorted set does not increase)
because a and b are equivalent from the sorted set's
perspective.


Virtually all Java core classes that implement Comparable have natural
orderings that are consistent with equals. One exception is
java.math.BigDecimal, whose natural ordering equates
BigDecimal objects with equal values and different precisions
(such as 4.0 and 4.00).


For the mathematically inclined, the *relation* that defines
the natural ordering on a given class C is:

```
       {(x, y) such that x.compareTo(y) <= 0}.
 
```
The *quotient* for this total order is:

```
       {(x, y) such that x.compareTo(y) == 0}.
 
```
It follows immediately from the contract for compareTo that the quotient is an *equivalence relation* on C, and that the natural ordering is a *total order* on C. When we say that a class's natural ordering is *consistent with equals*, we mean that the quotient for the natural ordering is the equivalence relation defined by the class's `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object)` method:

```
     {(x, y) such that x.equals(y)}. 
```


This interface is a member of the
[Java Collections Framework](https://developers.google.com/j2objc/javadoc/jre/openjdk-redirect.html?v=8&path=/technotes/guides/collections/index.html).

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html`

### Public Method Summary

|---|---|
| abstract int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html#compareTo(T))(T o) Compares this object with the specified object for order. |

## Public Methods

#### public abstract int
**compareTo**
(T o)

Compares this object with the specified object for order. Returns a
negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the specified object.

The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This
implies that x.compareTo(y) must throw an exception iff
y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive:
(x.compareTo(y)\>0 \&\& y.compareTo(z)\>0) implies
x.compareTo(z)\>0.

Finally, the implementor must ensure that x.compareTo(y)==0
implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for
all z.

It is strongly recommended, but *not* strictly required that
(x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any
class that implements the Comparable interface and violates
this condition should clearly indicate this fact. The recommended
language is "Note: this class has a natural ordering that is
inconsistent with equals."

In the foregoing description, the notation
sgn(*expression*) designates the mathematical
*signum* function, which is defined to return one of -1,
0, or 1 according to whether the value of
*expression* is negative, zero or positive.

##### Parameters

| o | the object to be compared. |
|---|---|

##### Returns

- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the specified object is null |
| [ClassCastException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassCastException.html) | if the specified object's type prevents it from being compared to this object. |
|---|---|