注意一下StringBuffer函数的toString输出结果就是当前字符串;StringBuffer继承的Object函数是:clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait;这些函数可以被调用;另外StringBuffer是final类,不可被重写; 答案1:将其转化为String格式,调用String的replace函数: public class Solution { public String replaceSpace(StringBuffer str) { ...