❮ String Methods
Example
String myStr = " Hello World! ";
System.out.println(myStr);
System.out.println(myStr.trim());Definition and Usage
The trim() method removes whitespace from both ends of a string.
Note
This method does not change the original string.
Syntax
public String trim()Parameters
None.
Technical Details
| Returns: | A String value, which is a copy of the string, without leading and trailing whitespace |
|---|