Android Guides | Samples

Java.Lang.IComparable

This interface should be implemented by all classes that wish to define a natural order of their instances.

See Also: IComparable

Syntax

[Android.Runtime.Register("java/lang/Comparable", "", "Java.Lang.IComparableInvoker")]
public interface IComparable : IJavaObject, IDisposable

Remarks

This interface should be implemented by all classes that wish to define a natural order of their instances. Java.Util.Collections.sort(java.util.List<T>) and java.util.Arrays#sort can then be used to automatically sort lists of classes that implement this interface.

The order rule must be both transitive (if x.compareTo(y) and y.compareTo(z) , then x.compareTo(z) must hold) and invertible (the sign of the result of x.compareTo(y) must be equal to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).

In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is zero, then the result of x.equals(y) should be true.

[Android Documentation]

Requirements

Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Java.Lang.IComparable are listed below.

Public Methods