Some of the commonly used string functions in Java are recorded for later use.
1 java.lang.string-->substring (int indexid)/string substring (int beginidex,int endindex)
Get substring: "Unhappy". Substring (2)--> "Happy" (intercept string from IndexID start to end)
"Emptiness". Substring--> "" (Return empty string)
"Hamburger". Substring (4,8)--> "Urger"
"Hamburger". Substring (4,20)--> "Java.lang.StringIndexOutOfBoundsException" exception
The same usage is used for java.lang.stringbuffer/stringbuilder.
2 Java.lang.string.c[color=green]oncat (String appendstr) [/color] tail connector substring
"Cares". Concat (s)--> "Caress"
"". Concat ("Hello")--> "Hello"
' To '. Concat ("get"). Concat ("her")--> "Together"
This method is only available in the String class
3 java.lang.String.charAt (int index): char (the letter corresponding to the position according to index)
"Hello". CharAt (4)--> ' O ' may throw an exception indexoutofboundsexception
4 Java.lang.String.lenght () This is nothing to say, but don't forget the array object does not have this function
5 java.lang.String.contentEquals (StringBuffer compstr): Boolean
Returns True if the comparison string is exactly the same as the contents of the COMPSTR
6 Java.lang.String.startsWith (String prefix): boolean
Java.lang.String.endsWith (String suffix): boolean
To determine whether a string begins and ends with strings
7 java.lang.String.indexOf (String str)/lastindexof (String str)
Get the first/last match to the location of STR
8 Java.lang.String.split (String regEx): string[]
To cut a string based on the regex of a regular expression
9 java.lang.String.toUpperCase ()/tolowercase the strings into uppercase/lowercase
Java.lang.String.toCharArray (): char[] Break a string into a character array
One public String intern () if and only if String1.equals (string2)
The public String replaceall (string regex,string Replacement)/replacefirst (string oldstr,string newstr)
Replace string
Java.lang.String.trim () Removes both ends of the string spaces