Java String Trim
# Java trim() Method
[Java String Class](#)
* * *
The trim() method is used to remove whitespace from both the beginning and end of a string.
### Syntax
public String trim()
### Parameters
* None
### Return Value
A string with whitespace removed from both ends.
### Example
public class Test { public static void main(String args[]) { String Str = new String(" www. "); System.out.print("Original Value :" ); System.out.println( Str ); System.out.print("Trimmed Value :" ); System.out.println( Str.trim() );}}
The output of the above program is:
Original Value : www. Trimmed Value :www.
* * Java String Class](#)
YouTip