Common string class of related classes
Common class contains several classes in the java developers frequently used today, let's talk about the string class:
Constructor String class:
The following two methods are configured to byte array is converted to a string
Format: String reference name = new String (byte array type name)
Meaning: all the byte to byte array, according to the current default encoding (UTF-8) is converted into a string
Format: reference name = new String (byte array type name, a, b);
Meaning: b byte number of the byte array index value from a start to a string
It is worth mentioning that, in utf-8 encoding, a Chinese character, 3 bytes , a letter 2 bytes
Converts a string to a byte array
Format: string getBytes ();.
Meaning: Converts a string into a byte array
StringBuilder and StringBuffer classes
Because the definition of a string String can not be defined by a deletion, while StringBuilder and StringBuffer class has string concatenation function
After you create a StringBuffer or StringBuilder object, append () to achieve string concatenation