Common Methods in string
1. Public char charat (INT index)
Returns the index characters in the string.
2. Public int length ()
Returns the string length.
3. Public int indexof (string Str)
Returns the first position of STR in the string.
Public int lastindexof (string Str)
Returns the last position of STR in the string.
4. Public Boolean equals (string S ):
Compare whether the string and another are the same
Public Boolean inclusignorecase (string another)
Compare whether the string and another are the same (case-insensitive)
The equals () method compares the characters in a string object, and the = Operator compares whether two objects reference the same instance.
5. Public String Replace (char oldchar, char newchar)
Replace oldchar with newchar in the string
String Replace (charsequence original, charsequence replacement)
Replacement to replace original
6. Public Boolean startswith (string prefix)
Determines whether a string starts with a prefix.
7. Public Boolean endswith (string suffix)
Judge whether the string ends with suffix
8. Public String touppercase ()
Returns the string in uppercase.
9. Public String tolowercase ()
Returns the string in lowercase.
10. Public string substring (INT beginindex)
Returns the substring from beginindex to the end of the string.
11. Public string substring (INT beginindex, int endindex)
Returns the substring from beginindex to endindex.
13. Public String trim ()
Removes spaces at the beginning and end of a string.
14. Public int compareto (string S ):
If the current string is the same as S, 0 is returned; if it is greater than S, a positive value is returned; if it is less than S, a negative value is returned.
Public int comparetoignore (string S): case-insensitive comparison
15. Public Boolean regionmatches (INT firststart, string other, int otherstart, int length ):
Compares a specific region in a string with a specific region.
Public Boolean regionmatches (Boolean B, int firststart, string other, int otherstart, int length)
You can use parameter B to determine whether to ignore case sensitivity.