Check out example codes for "remove spaces at beginning and end of string java". It will help you in understanding the concepts better.

Code Example 1

String withSpaces = "  Hi  ";
String withoutSpaces = withSpaces.trim();

Learn ReactJs, React Native from akashmittal.com