StringBuffer的反转功能
StringBuffer的替换功能:
/* * StringBuffer的反转功能: * public StringBuffer reverse() */
代码实现案例:
public class StringBufferDemo { public static void main(String[] args) { //创建缓冲区对象 StringBuffer buffer = new StringBuffer(); //添加数据 buffer.append("hello"); System.out.println("buffer:"+buffer); // public StringBuffer reverse() buffer.reverse(); System.out.println("buffer:"+buffer); } }
运行结果:
buffer:hello
buffer:olleh