First, StringBuffer class
StringBuffer is a variable character sequence.
1.1 Constructors
StringBuffer () constructs a character buffer without characters, with an initial capacity of 16 characters.
StringBuffer (int capacity) constructs a character buffer with the specified initial capacity
StringBuffer (String str) constructs a character buffer with the specified string, with an initial capacity of string capacity plus 16
Common methods of 1.2 StringBuffer class (StringBuffer no static method)
Extension of 1.2.1 StringBuffer class
Public StringBuffer append (Object obj) parameter can be int,char,string,double, etc.
Public stringbuffer Insert (int offset, data type) The data type can be an integer type, a character, a string, a Boolean type, and so on, and offset offsets indicate the index position of the insertion string
1.2.2 length and capacity of StringBuffer class objects
public int Length () returns the number of characters that the current object contains
public int Capacity () returns the number of character spaces allocated by the current object and expands to twice times the original size plus 2
1.2.3 Modification
public void Setcharat (int index,char ch)
1.2.4 Other
char charAt (int index)
void GetChars (int srcbegin, int srcend, char[] DST, int dstbegin) copy substrings to the target character array
String substring (int start)
string substring (int start, int end) intercepts substrings
Stingbuffer reverse () inverted
Second, array
2.1 Anonymous Arrays
1. An anonymous array can be assigned to an already existing array variable, regardless of the original array.
2. The type of the array variable must be consistent with the type of the anonymous array
2.2 Arrays are also objects
Length is an attribute in the array, not a method.
Java Learning Diary-4 StringBuffer class and array