问题为将类似"Hello world!"变成"Hello world!"
问题思路:先切割字符串,再将字符串重新组合
核心代码
public void filter(String s){
String[] b = s.split("\\s+");
StringBuffer stringBuffer = new StringBuffer();
for(String c:b){
stringBuffer.append(" "+c);
}
System.out.print(stringBuffer.toString());
}
转载于:https://blog.51cto.com/golearning/2087870