美文网首页
字符串的拼接和反转

字符串的拼接和反转

作者: 稻草人_9ac7 | 来源:发表于2020-06-12 18:08 被阅读0次
// TestStringBuffer.java 主函数
package demo1;

public class TestStringBuffer {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        TestBuff test = new TestBuff();
        test.append("哈哈,");
    }
}

// TestBuff.java构造函数
package demo1;

 class TestBuff {
     
    public void append (String str) {
        StringBuffer strbuff = new StringBuffer(str);
        strbuff.append("大家好");
        System.out.println("拼接后:" + strbuff);
        this.reverse(strbuff);
    }
    public void reverse (StringBuffer str) {
        StringBuffer strbuff = new StringBuffer (str);
        strbuff.reverse();
        System.out.println("反转后:" + strbuff);
    }
}

执行结果

相关文章

网友评论

      本文标题:字符串的拼接和反转

      本文链接:https://www.haomeiwen.com/subject/yjentktx.html