去掉字符串首位空格String s =" Hello World ";System.out.println(s.trim());//Hello World
去除指定字符串的前后空格
str.trim():去掉字符串首尾的空格。str.replace(" ", ""); 去掉所有空格,包括首尾、中间