These three methods are used to delete certain characters that appear at the beginning and end of a string. Trim () deletes spaces in the header and tail of a string. The deletion process is from the outside to the inner until a non-space character is encountered, therefore, no matter how many consecutive spaces exist before and after it is deleted. Trimstart () only deletes spaces in the string header. Trimend () only removes spaces at the end of the string.
If these three functions carry the parameters of the struct array, they are to delete any character that appears in the struct array. For example, trim ("ABCD ". tochararray () is to delete the, B, C, or D characters in the header and tail of a string, the deletion process ends until it encounters a character that is neither a nor B nor C nor D.
The most common misunderstanding here is that the "ABCD" string is deleted. For example:
String S = "from dual Union all ";
S = S. Trim (). trimend ("Union all". tochararray ());
Some people may think that the final result of S is "from dual", but the real result is "from D ". Note that the delete object executed in this writing method is any character in the character array, rather than a string consisting of these characters!