learning java StringBuilder 类

        StringBuilder  s1 = new StringBuilder();

        s1.append("panzidong");
        s1.insert(0,"hong,");
        s1.replace(4,5,"!");
        s1.reverse();

        System.out.println(s1);
        System.out.println(s1);
        System.out.println(s1.length());
        System.out.println(s1.capacity());
        s1.setLength(4);
        System.out.println(s1);

output:

gnodiznap!gnoh
gnodiznap!gnoh
14
16
gnod

 

posted @ 2019-07-25 16:09  嵌入式实操  阅读(101)  评论(0编辑  收藏  举报