This String method removes beginning and ending spaces of the given string. code example
Example 1: how to strip trailing spaces in java
String str = new String(" apples ");
str.trim(); // result is a nes string "apple"
Example 2: Which method in an be used to remove any whitespace from both the beginning and the end of a string?
str = "hello "
print(str.trim())