用于删除字符串的头尾空白符。

语法:public String trim()

返回值:删除头尾空白符的字符串。

 

 

public class Test {
    public static void main(String args[]) {
        String Str = new String("    xiaohouzi.com    ");
        System.out.print("原始值 :" );
        System.out.println( Str );

        System.out.print("删除头尾空白 :" );
        System.out.println( Str.trim() );
    }
}

 

执行结果为:原始值 :    xiaohouzi.com

       删除头尾空白 :xiaohouzi.com

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2022-01-02
  • 2021-06-01
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2021-12-09
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案