问题为将类似"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());
}
原文地址:http://blog.51cto.com/golearning/2087870
时间: 2024-10-10 07:55:26