|
1. String Array
Constructor:
String [] array = new string [5];
String [] array = new string [] {"AA", "BB", "CC "};
String [] array = {"AA", "BB", "CC "};
String arrays are also seen as objects:
Attribute: length (different from the string method length ())
Common Methods: void system. arraycopy (object [] From, intfromindex, object [] to, int fromindex, int count), a static method of the system
2. String cache stringbuffer
Once declared, the string class object cannot be changed. The stringbuffer cache class implements a variable character sequence.
The basic operations on stringbuffer are append and insert. They accept arbitrary data, convert the given data to a string, and add the string to the end of the buffer or insert it to the specified place.
Public final classStringbuffer
Extends object
Implements serializable, charsequence
|
Constructor Summary |
|
Stringbuffer()
Construct a string buffer with no characters. The initial size is 16 characters. |
|
|
Stringbuffer(Charsequence SEQ)
Public java. Lang. stringbuilder (charsequence SEQ) constructs a string buffer that contains the same characters as the specified charsequence. |
|
|
Stringbuffer(INT capacity)
Construct a string buffer with no characters but a specified initial capacity. |
|
|
Stringbuffer(String Str)
Constructs a string buffer and initializes its content to the specified string content. |
|
Other methods:
Stringbuffer is converted to a string object: tostring ()
|
String |
Tostring()
Returns a string representing the data in this sequence. |
Stringbuffer extension appand ():
|
Stringbuffer |
Append(Boolean B)
Appends the string representation of the Boolean argument to the sequence. |
|
Stringbuffer |
Append(Char C)
Appends the string representation of the char argument to this sequence. |
|
Stringbuffer |
Append(Char [] Str)
Appends the string representation of the char array argument to this sequence. |
|
Stringbuffer |
Append(Char [] STR, int offset, int Len)
Appends the string representation of a subarray of the char array argument to this sequence. |
|
Stringbuffer |
Append(Charsequence S)
Add the specified charsequence to the sequence. |
|
Stringbuffer |
Append(Charsequence S, int start, int end)
Appends a subsequence of the specified charsequence to this sequence. |
Wait .......
Any type will be converted into strings and added to the cache end
Insert () of stringbuffer ():
|
Stringbuffer |
Insert(INT offset, object OBJ)
Inserts the string representation of the object argument into this character sequence. |
|
Stringbuffer |
Insert(INT offset, string Str)
Inserts the string into this character sequence. |
|
Stringbuffer |
Insert(INT offset, char [] Str)
Inserts the string representation of the char array argument into this sequence. |
|
Stringbuffer |
Insert(INT index, char [] STR, int offset, int Len)
Inserts the string representation of a subarray of the STR array argument into this sequence. |
Wait ......
Other typical operations:
|
Int |
Length()
Returns the length (character count ). |
|
Char |
Charat(INT index)
Returns the char value in this sequence at the specified index. |
|
String |
Substring(INT start)
Returns a new string that contains a subsequence of characters currently contained in this character sequence. |
|
Int |
Indexof(StringStr)
Returns the index within this string of the first occurrence of the specified substring. |
|
Stringbuffer |
Replace(INT start, int end,StringStr)
Replaces the characters in a substring of this sequence with characters in the specified string. |
|
Stringbuffer |
Delete(INT start, int end)
Removes the characters in a substring of this sequence. |
And so on ..... |