trim() 方法是用于删除字符串的头尾空白符(只有头和尾)。返回值是删除头尾空白符的字符串
public class test1 {
public static void main(String[] args) {
String Str = " chenglaodeia ";
System.out.print("原始值 :" );
System.out.println( Str );
System.out.print("删除头尾空白 :" );
System.out.println( Str.trim() );
}
}
原始值 : chenglaodeia
删除头尾空白 :chenglaodeia