Sdílet prostřednictvím


Objects.Compare(Object, Object, IComparator) Method

Definition

Returns 0 if the arguments are identical and c.compare(a, b) otherwise.

[Android.Runtime.Register("compare", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/Comparator;)I", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static int Compare (Java.Lang.Object? a, Java.Lang.Object? b, Java.Util.IComparator c);
[<Android.Runtime.Register("compare", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/Comparator;)I", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member Compare : Java.Lang.Object * Java.Lang.Object * Java.Util.IComparator -> int

Parameters

a
Object

an object

b
Object

an object to be compared with a

c
IComparator

the Comparator to compare the first two arguments

Returns

0 if the arguments are identical and c.compare(a, b) otherwise.

Attributes

Remarks

Returns 0 if the arguments are identical and c.compare(a, b) otherwise. Consequently, if both arguments are null 0 is returned.

Note that if one of the arguments is null, a NullPointerException may or may not be thrown depending on what ordering policy, if any, the Comparator Comparator chooses to have for null values.

Java documentation for java.util.Objects.compare(T, T, java.util.Comparator<? super T>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to