trim():去掉字符串首尾的空格。
- public static void main(String arg[]){
- String a=" hello world ";
- String b="hello world";
- System.out.println(b.equals(a));
- a=a.trim();//去掉字符串首尾的空格
- System.out.println(a.equals(b));
- }
a: hello world ,false
a:hello world,true