1. Obtain
int indexOf(int c)
int indexOf(int c, int start)
char charAt(int index)
2. judge
It determines whether a string contains
boolean contains(CharSequence cs)
indexOf () // it may also be used to determine whether comprising
Determine whether there is content
boolean isEmpty () // determine whether there is content
In order to determine whether the end of the specified content
boolearn endsWith ( )
Analyzing the content of the string is the same
boolearn equals () // method overrides Object
Determine whether the same content, and ignore case
boolearn equalsIgnoreCase( )
3. Conversion
It will turn into a string array of characters:
Constructor:
String(char[] data)
String (char [] data, int offset, int charCount) // turn portion of the array of characters to a string
Static methods:
- static String copyValueOf(char[] data, int start, int length)
- static String copyValueOf(char[] data) static String
- valueOf(char[] data)
String transformed into an array of characters
char[] toCharArray()
The byte array translated into strings String (byte [] data)
Turn the string into a byte array
byte[] getBytes()
The basic data types into a string
static String valueOf(int value)
4. Replace
Note: string can not be changed
String replace (char oldChar, char newChar) // returns the new string
5. Cutting
String [] split (String regularExpression) // returns an array of strings
6. substring string acquisition portion
String substring (int start) // string from the beginning to the final
String substring (int start, int end) // includes head, without trailing
7. Conversion removing spaces, more
Case conversion
- String toUpperCase()
- String toLowerCase()
Remove excess spaces
String trim () // remove the spaces at both ends
Comparing two strings natural order
int compareTo(String string)
Reproduced in: https: //my.oschina.net/itfanr/blog/195666