In the process of developing a project, it is sometimes necessary to transfer data to the server when requesting an interface. The data you enter in the input box may have spaces, which may be at the beginning and end of the string or in the middle of the string, and must be removed. We can remove spaces in the following ways.
Delete leading and trailing spaces -trim ():
str.getText()。 toString()。 trim();
Delete all spaces -replaceAll ("","");
str.getText()。 toString()。 replaceAll(" "," ");