java部分新知识点
1、trim() 方法用于删除字符串的头尾空白符。
1 public class Test { 2 public static void main(String args[]) { 3 String Str = new String(" www.runoob.com "); 4 System.out.print("原始值 :" ); 5 System.out.println( Str ); 6 7 System.out.print("删除头尾空白 :" ); 8 System.out.println( Str.trim() ); 9 } 10 }
执行结果:
原始值 : www.runoob.com
删除头尾空白 :www.runoob.com

浙公网安备 33010602011771号