Aracılığıyla paylaş


Arrays.Compare Method

Definition

Overloads

Compare(Byte[], Int32, Int32, Byte[], Int32, Int32)

Compares two byte arrays lexicographically over the specified ranges.

Compare(Char[], Int32, Int32, Char[], Int32, Int32)

Compares two char arrays lexicographically over the specified ranges.

Compare(Double[], Int32, Int32, Double[], Int32, Int32)

Compares two double arrays lexicographically over the specified ranges.

Compare(Int16[], Int32, Int32, Int16[], Int32, Int32)

Compares two short arrays lexicographically over the specified ranges.

Compare(Object[], Int32, Int32, Object[], Int32, Int32, IComparator)

Compares two Object arrays lexicographically over the specified ranges.

Compare(Int64[], Int32, Int32, Int64[], Int32, Int32)

Compares two long arrays lexicographically over the specified ranges.

Compare(Single[], Int32, Int32, Single[], Int32, Int32)

Compares two float arrays lexicographically over the specified ranges.

Compare(Boolean[], Int32, Int32, Boolean[], Int32, Int32)

Compares two boolean arrays lexicographically over the specified ranges.

Compare(Int32[], Int32, Int32, Int32[], Int32, Int32)

Compares two int arrays lexicographically over the specified ranges.

Compare(Object[], Int32, Int32, Object[], Int32, Int32)

Compares two Object arrays lexicographically over the specified ranges.

Compare(Int32[], Int32[])

Compares two int arrays lexicographically.

Compare(Single[], Single[])

Compares two float arrays lexicographically.

Compare(Int64[], Int64[])

Compares two long arrays lexicographically.

Compare(Int16[], Int16[])

Compares two short arrays lexicographically.

Compare(Double[], Double[])

Compares two double arrays lexicographically.

Compare(Char[], Char[])

Compares two char arrays lexicographically.

Compare(Byte[], Byte[])

Compares two byte arrays lexicographically.

Compare(Boolean[], Boolean[])

Compares two boolean arrays lexicographically.

Compare(Object[], Object[])

Compares two Object arrays, within comparable elements, lexicographically.

Compare(Object[], Object[], IComparator)

Compares two Object arrays lexicographically using a specified comparator.

Compare(Byte[], Int32, Int32, Byte[], Int32, Int32)

Compares two byte arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([BII[BII)I", "", ApiSince=33)]
public static int Compare (byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([BII[BII)I", "", ApiSince=33)>]
static member Compare : byte[] * int * int * byte[] * int * int -> int

Parameters

a
Byte[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Byte[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two byte arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte#compare(byte, byte), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(byte[], int, int, byte[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(byte[], int, int, byte[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(byte[], int, int, byte[], int, int).

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

Compare(Char[], Int32, Int32, Char[], Int32, Int32)

Compares two char arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([CII[CII)I", "", ApiSince=33)]
public static int Compare (char[] a, int aFromIndex, int aToIndex, char[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([CII[CII)I", "", ApiSince=33)>]
static member Compare : char[] * int * int * char[] * int * int -> int

Parameters

a
Char[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Char[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two char arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Character#compare(char, char), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(char[], int, int, char[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(char[], int, int, char[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(char[], int, int, char[], int, int).

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

Compare(Double[], Int32, Int32, Double[], Int32, Int32)

Compares two double arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([DII[DII)I", "", ApiSince=33)]
public static int Compare (double[] a, int aFromIndex, int aToIndex, double[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([DII[DII)I", "", ApiSince=33)>]
static member Compare : double[] * int * int * double[] * int * int -> int

Parameters

a
Double[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Double[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two double arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Double#compare(double, double), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(double[], int, int, double[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(double[], int, int, double[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(double[], int, int, double[], int, int).

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

Compare(Int16[], Int32, Int32, Int16[], Int32, Int32)

Compares two short arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([SII[SII)I", "", ApiSince=33)]
public static int Compare (short[] a, int aFromIndex, int aToIndex, short[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([SII[SII)I", "", ApiSince=33)>]
static member Compare : int16[] * int * int * int16[] * int * int -> int

Parameters

a
Int16[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Int16[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two short arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short#compare(short, short), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(short[], int, int, short[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(short[], int, int, short[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(short[], int, int, short[], int, int).

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

Compare(Object[], Int32, Int32, Object[], Int32, Int32, IComparator)

Compares two Object arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([Ljava/lang/Object;II[Ljava/lang/Object;IILjava/util/Comparator;)I", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static int Compare (Java.Lang.Object[] a, int aFromIndex, int aToIndex, Java.Lang.Object[] b, int bFromIndex, int bToIndex, Java.Util.IComparator cmp);
[<Android.Runtime.Register("compare", "([Ljava/lang/Object;II[Ljava/lang/Object;IILjava/util/Comparator;)I", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member Compare : Java.Lang.Object[] * int * int * Java.Lang.Object[] * int * int * Java.Util.IComparator -> int

Parameters

a
Object[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Object[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

cmp
IComparator

the comparator to compare array elements

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two Object arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing with the specified comparator two elements at a relative index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(Object[], int, int, Object[], int, int) for the definition of a common and proper prefix.)

Added in 9.

Java documentation for java.util.Arrays.compare(T[], int, int, T[], int, int, 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

Compare(Int64[], Int32, Int32, Int64[], Int32, Int32)

Compares two long arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([JII[JII)I", "", ApiSince=33)]
public static int Compare (long[] a, int aFromIndex, int aToIndex, long[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([JII[JII)I", "", ApiSince=33)>]
static member Compare : int64[] * int * int * int64[] * int * int -> int

Parameters

a
Int64[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Int64[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two long arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long#compare(long, long), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(long[], int, int, long[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(long[], int, int, long[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(long[], int, int, long[], int, int).

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

Compare(Single[], Int32, Int32, Single[], Int32, Int32)

Compares two float arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([FII[FII)I", "", ApiSince=33)]
public static int Compare (float[] a, int aFromIndex, int aToIndex, float[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([FII[FII)I", "", ApiSince=33)>]
static member Compare : single[] * int * int * single[] * int * int -> int

Parameters

a
Single[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Single[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two float arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Float#compare(float, float), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(float[], int, int, float[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(float[], int, int, float[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(float[], int, int, float[], int, int).

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

Compare(Boolean[], Int32, Int32, Boolean[], Int32, Int32)

Compares two boolean arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([ZII[ZII)I", "", ApiSince=33)]
public static int Compare (bool[] a, int aFromIndex, int aToIndex, bool[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([ZII[ZII)I", "", ApiSince=33)>]
static member Compare : bool[] * int * int * bool[] * int * int -> int

Parameters

a
Boolean[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Boolean[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two boolean arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Boolean#compare(boolean, boolean), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(boolean[], int, int, boolean[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(boolean[], int, int, boolean[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(boolean[], int, int, boolean[], int, int).

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

Compare(Int32[], Int32, Int32, Int32[], Int32, Int32)

Compares two int arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([III[III)I", "", ApiSince=33)]
public static int Compare (int[] a, int aFromIndex, int aToIndex, int[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([III[III)I", "", ApiSince=33)>]
static member Compare : int[] * int * int * int[] * int * int -> int

Parameters

a
Int32[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Int32[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two int arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer#compare(int, int), at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(int[], int, int, int[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(int[], int, int, int[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(int[], int, int, int[], int, int).

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

Compare(Object[], Int32, Int32, Object[], Int32, Int32)

Compares two Object arrays lexicographically over the specified ranges.

[Android.Runtime.Register("compare", "([Ljava/lang/Comparable;II[Ljava/lang/Comparable;II)I", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Comparable<? super T>" })]
public static int Compare (Java.Lang.Object[] a, int aFromIndex, int aToIndex, Java.Lang.Object[] b, int bFromIndex, int bToIndex);
[<Android.Runtime.Register("compare", "([Ljava/lang/Comparable;II[Ljava/lang/Comparable;II)I", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Comparable<? super T>" })>]
static member Compare : Java.Lang.Object[] * int * int * Java.Lang.Object[] * int * int -> int

Parameters

a
Object[]

the first array to compare

aFromIndex
Int32

the index (inclusive) of the first element in the first array to be compared

aToIndex
Int32

the index (exclusive) of the last element in the first array to be compared

b
Object[]

the second array to compare

bFromIndex
Int32

the index (inclusive) of the first element in the second array to be compared

bToIndex
Int32

the index (exclusive) of the last element in the second array to be compared

Returns

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two Object arrays lexicographically over the specified ranges.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements of type T at a relative index i within the respective arrays that is the prefix length, as if by:

{@code
                Comparator.nullsFirst(Comparator.<T>naturalOrder()).
                    compare(a[aFromIndex + i, b[bFromIndex + i])
            }

Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See #mismatch(Object[], int, int, Object[], int, int) for the definition of a common and proper prefix.)

The comparison is consistent with #equals(Object[], int, int, Object[], int, int) equals, more specifically the following holds for arrays a and b with specified ranges [aFromIndex, atoIndex) and [bFromIndex, btoIndex) respectively:

{@code
                Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
                    (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(T[], int, int, T[], int, int).

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

Compare(Int32[], Int32[])

Compares two int arrays lexicographically.

[Android.Runtime.Register("compare", "([I[I)I", "", ApiSince=33)]
public static int Compare (int[]? a, int[]? b);
[<Android.Runtime.Register("compare", "([I[I)I", "", ApiSince=33)>]
static member Compare : int[] * int[] -> int

Parameters

a
Int32[]

the first array to compare

b
Int32[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two int arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer#compare(int, int), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(int[], int[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(int[], int[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(int[], int[]).

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

Compare(Single[], Single[])

Compares two float arrays lexicographically.

[Android.Runtime.Register("compare", "([F[F)I", "", ApiSince=33)]
public static int Compare (float[]? a, float[]? b);
[<Android.Runtime.Register("compare", "([F[F)I", "", ApiSince=33)>]
static member Compare : single[] * single[] -> int

Parameters

a
Single[]

the first array to compare

b
Single[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two float arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Float#compare(float, float), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(float[], float[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(float[], float[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(float[], float[]).

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

Compare(Int64[], Int64[])

Compares two long arrays lexicographically.

[Android.Runtime.Register("compare", "([J[J)I", "", ApiSince=33)]
public static int Compare (long[]? a, long[]? b);
[<Android.Runtime.Register("compare", "([J[J)I", "", ApiSince=33)>]
static member Compare : int64[] * int64[] -> int

Parameters

a
Int64[]

the first array to compare

b
Int64[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two long arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long#compare(long, long), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(long[], long[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(long[], long[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(long[], long[]).

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

Compare(Int16[], Int16[])

Compares two short arrays lexicographically.

[Android.Runtime.Register("compare", "([S[S)I", "", ApiSince=33)]
public static int Compare (short[]? a, short[]? b);
[<Android.Runtime.Register("compare", "([S[S)I", "", ApiSince=33)>]
static member Compare : int16[] * int16[] -> int

Parameters

a
Int16[]

the first array to compare

b
Int16[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two short arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short#compare(short, short), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(short[], short[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(short[], short[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(short[], short[]).

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

Compare(Double[], Double[])

Compares two double arrays lexicographically.

[Android.Runtime.Register("compare", "([D[D)I", "", ApiSince=33)]
public static int Compare (double[]? a, double[]? b);
[<Android.Runtime.Register("compare", "([D[D)I", "", ApiSince=33)>]
static member Compare : double[] * double[] -> int

Parameters

a
Double[]

the first array to compare

b
Double[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two double arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Double#compare(double, double), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(double[], double[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(double[], double[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(double[], double[]).

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

Compare(Char[], Char[])

Compares two char arrays lexicographically.

[Android.Runtime.Register("compare", "([C[C)I", "", ApiSince=33)]
public static int Compare (char[]? a, char[]? b);
[<Android.Runtime.Register("compare", "([C[C)I", "", ApiSince=33)>]
static member Compare : char[] * char[] -> int

Parameters

a
Char[]

the first array to compare

b
Char[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two char arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Character#compare(char, char), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(char[], char[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(char[], char[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(char[], char[]).

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

Compare(Byte[], Byte[])

Compares two byte arrays lexicographically.

[Android.Runtime.Register("compare", "([B[B)I", "", ApiSince=33)]
public static int Compare (byte[]? a, byte[]? b);
[<Android.Runtime.Register("compare", "([B[B)I", "", ApiSince=33)>]
static member Compare : byte[] * byte[] -> int

Parameters

a
Byte[]

the first array to compare

b
Byte[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two byte arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte#compare(byte, byte), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(byte[], byte[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(byte[], byte[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(byte[], byte[]).

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

Compare(Boolean[], Boolean[])

Compares two boolean arrays lexicographically.

[Android.Runtime.Register("compare", "([Z[Z)I", "", ApiSince=33)]
public static int Compare (bool[]? a, bool[]? b);
[<Android.Runtime.Register("compare", "([Z[Z)I", "", ApiSince=33)>]
static member Compare : bool[] * bool[] -> int

Parameters

a
Boolean[]

the first array to compare

b
Boolean[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two boolean arrays lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Boolean#compare(boolean, boolean), at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(boolean[], boolean[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

The comparison is consistent with #equals(boolean[], boolean[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(boolean[], boolean[]).

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

Compare(Object[], Object[])

Compares two Object arrays, within comparable elements, lexicographically.

[Android.Runtime.Register("compare", "([Ljava/lang/Comparable;[Ljava/lang/Comparable;)I", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Comparable<? super T>" })]
public static int Compare (Java.Lang.Object[]? a, Java.Lang.Object[]? b);
[<Android.Runtime.Register("compare", "([Ljava/lang/Comparable;[Ljava/lang/Comparable;)I", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Comparable<? super T>" })>]
static member Compare : Java.Lang.Object[] * Java.Lang.Object[] -> int

Parameters

a
Object[]

the first array to compare

b
Object[]

the second array to compare

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two Object arrays, within comparable elements, lexicographically.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements of type T at an index i within the respective arrays that is the prefix length, as if by:

{@code
                Comparator.nullsFirst(Comparator.<T>naturalOrder()).
                    compare(a[i], b[i])
            }

Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(Object[], Object[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal. A null array element is considered lexicographically less than a non-null array element. Two null array elements are considered equal.

The comparison is consistent with #equals(Object[], Object[]) equals, more specifically the following holds for arrays a and b:

{@code
                Arrays.equals(a, b) == (Arrays.compare(a, b) == 0)
            }

Added in 9.

Java documentation for java.util.Arrays.compare(T[], 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

Compare(Object[], Object[], IComparator)

Compares two Object arrays lexicographically using a specified comparator.

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

Parameters

a
Object[]

the first array to compare

b
Object[]

the second array to compare

cmp
IComparator

the comparator to compare array elements

Returns

the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array

Attributes

Remarks

Compares two Object arrays lexicographically using a specified comparator.

If the two arrays share a common prefix then the lexicographic comparison is the result of comparing with the specified comparator two elements at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See #mismatch(Object[], Object[]) for the definition of a common and proper prefix.)

A null array reference is considered lexicographically less than a non-null array reference. Two null array references are considered equal.

Added in 9.

Java documentation for java.util.Arrays.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