* this string; a value less than {@code 0} if this string * is lexicographically less than the string argument; and a * value greater than {@code 0} if this string is * lexicographically greater than the string argument. */ public int compareTo(String anotherString) { int len1 = val...
compareTo in interface Comparable<String> Parameters: anotherString - the String to be compared. Returns: the value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this ...
The equalsIgnoreCase() method of the String class is used to compare two strings lexicographically, ignoring differences in case. It returns true if and only if the argument passed to it is a String object that represents the same sequence of characters as the original string, regardless of diff...
int java.lang.String.compareTo(String anotherString)Compares two stringslexicographically(字典序; 按字典顺序;). The comparison is based on theUnicodevalue of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence re...
How do you compare two strings in a Java program? JavaStringimplements theComparableinterface, which has two variants of thecompareTo()method. ThecompareTo(String anotherString)method compares theStringobject with theStringargument passed lexicographically. If theStringobject precedes the argument passed...
Returns the number of Unicode code points in the specified text range of this String. CompareTo(String) Compares two strings lexicographically. CompareToIgnoreCase(String) Compares two strings lexicographically, ignoring case differences. Concat(String) Concatenates the specified string to the end of...
CodePointAt(Int32) Added in 1. CodePointBefore(Int32) Added in 1. CodePointCount(Int32, Int32) Added in 1. CompareTo(StringBuffer) Compares two StringBuffer instances lexicographically. Delete(Int32, Int32) Added in 1. DeleteCharAt(Int32) Added in 1. Dispose() (Inherited from Object)...
Java String compareTo() method example. Learn to compare two strings lexicographically. We can consider this string comparison dictionary based comparison.
Definition and Usage TheequalsIgnoreCase()method compares two strings, ignoring lower case and upper case differences. This method returns true if the strings are equal, and false if not. Tip:Use thecompareToIgnoreCase()method to compare two strings lexicographically, ignoring case differences. ...
Java String compareTo() method example. Learn to compare two strings lexicographically. We can consider this string comparison dictionary based comparison. Java String equalsIgnoreCase() Java String.equalsIgnoreCase() compares the current string with the specified string in a case-insensitive manner. Lear...