The trim() Method
This method trims leading and trailing whitespaces and returns a copy of the invoking string. The general form is:
String trim();
Consider the following example:
TrimTest.java
class ConcatTest
{
public static void main(String arg[])
{
String str=" Hello Java";
System.out.println(str);
System.out.println(str.trim());
}
}
Will give the following Output:
Hello Java
Hello Java
Next Topic Shahbaz
0 comments:
Post a Comment