Home Tutorial Java StringExamples java.lang.String.trim()

 
 

Share on Google+Share on Google+
java.lang.String.trim()
Posted on: March 22, 2005 at 12:00 AM
Advertisement
trim() is a string class method in Java that removes all the whitespaces as well as ASCII control characters.

trim() is a string class method in Java that removes all the whitespaces as well as ASCII control characters. String.trim() method removes leading and trailing whitespace(blank spaces) of the string. Just go through the example given below...

a simple example of trim method:

public class StringTrim {

public static void main(String[] args) {

String test = " trim method Remove all spaces. ";

System.out.println("**"+test+"**");

System.out.println("**"+test.trim()+"**");

 //.trim() method will remove the spaces

}

}

the output is:

**trim method Remove all spaces. **
**trim method Remove all spaces.**

Advertisement

Related Tags for java.lang.String.trim():


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 22, 2005

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com