Trim method removes white space characters (spaces, tabs, newlines ... ) from the start and end of a word. - Java Language Basics

Java examples for Language Basics:String

Description

Trim method removes white space characters (spaces, tabs, newlines ... ) from the start and end of a word.

Demo Code

public class Main {
  public static void main(String[] args) {
    String s = "   test test  ";
    s = s.trim();/*from  w ww . ja va 2s .c o m*/
    System.out.println(s);
  }

}

Related Tutorials