<a href= "http://www.goodprogrammer.org/" target= "blank" >android training </a>------My Java notes and look forward to communicating with you!
1.StringBuffer is a string buffer, which is a container.
Features: 1) The length is changeable. 2) Multiple data types can be manipulated in bytes. 3) will eventually become a string by the ToString method.
Method of 2.StringBuffer:
1) storage.
StringBuffer append (): Adds the specified data as a parameter to the end of the existing data.
StringBuffer Insert (Index, data): You can insert data into the specified index position.
2) Delete.
StringBuffer Delete (start,end): Deletes the data in the buffer, contains start, and does not contain end.
StringBuffer Deletecharat (Index): Deletes the character at the specified position.
3) get.
char charAt (int index)
int indexOf (String str)
int lastIndexOf (String str)
int Length ()
String substring (int start, int end)
4) modification.
StringBuffer replace (start,end,string);
void Setcharat (int index, char ch);
5) Invert.
StringBuffer reverse ();
6) stores the specified data in the buffer in the specified character array.
void GetChars (int srcbegin, int srcend, char[] DST, int dstbegin)
3. New Type StringBuilder
1) StringBuilder appeared after the JDK1.5 version.
2) StringBuffer is thread synchronization. StringBuilder is a thread that is out of sync.
3) After development, it is recommended to use StringBuilder
Upgrade three factors: 1, improve efficiency. 2, simplify writing. 3, improve security.
Java Learning StringBuffer < good programmer training camp;