Common methods of String class


The common method

split() of the String class is to split the string. The parentheses are the split conditions. What is the split, return the split string

replace(char oldChaar, char newChar) Returns a new string, which is replaced by newChar The function of equals() obtained by oldChar in this

string

is to compare whether two strings are equal

contains() Returns true if and only if this string contains the specified sequence of char values

​​subString(int beginIndex) or subString (int beginIndex , int beginIndex)

returns a new string that is a substring of the secondary string

compareTo(String anotherString) compares two strings lexicographically

compareToIgnoreCase(String str) compares two strings lexicographically, Case is not considered.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324674978&siteId=291194637