StringSorter.compare

Overview | Methods | Fields | This Package | All Packages

StringSorter.compare

Compares two strings.

Syntax

public static int compare( String s1, String s2 )

public static int compare( String s1, String s2, int options )

public static int compare( Locale locale, String s1, String s2, int options )

Parameters

s1

The first string.

s2

The second string.

locale

A Locale object that represents the locale to be used.

options

The string comparison flags. You can specify any bitwise combination of the following flags:

Return Value

Returns -1 if s1 is less than s2, 0 if s1 equals s2, or 1 if s1 is greater than s2.

Remarks

If the two strings are different lengths, they are compared up to the length of the shortest one. If they are equal to that point, the return value indicates that the longer string is greater. Note that if the return value is 0, the two strings are equal in the collation sense, though not necessarily identical.

A null string always sorts before a non-null string. Two null strings are considered equal.