05.0 Java Notes‎ > ‎Java: String‎ > ‎

Java String: trim()





          /**
     * An example of remove leading and trailing white space in a String 
     */
    public void trimExample1()
    {
      String str;
      str = "  a string with white space at the beginning and end of the string      ";
      System.out.println(str);
      str = str.trim();
      System.out.println(str);

    }

Comments