string 去除所有空格 String id=" wh z "; String str2 = id.replaceAll(" ", ""); System.out.println(str2); 返回结果 whz