Check out example codes for "how to strip trailing spaces in java". It will help you in understanding the concepts better.

Code Example 1

String str = new String(" apples ");
str.trim(); // result is a nes string "apple"

Learn ReactJs, React Native from akashmittal.com