标签:api sub src class main div ges bsp index
1 public class Copy3 {
2
3 public static void main(String[] args) {
4 //构造实例化
5 StringBuffer strbu = new StringBuffer("hello world\t");
6 char[] a = {‘l‘,‘o‘,‘y‘,‘o‘,‘u‘};
7 //调用方法
8
9 System.out.println(1+"\t"+strbu.append(true)); //append(boolean b);
10 System.out.println(2+"\t"+strbu.append(‘a‘)); //append(char b);
11 System.out.println(3+"\t"+strbu.append(a)); //append(char[] b);
12 System.out.println(4+"\t"+strbu.capacity()); //capacity();
13 System.out.println(5+"\t"+strbu.charAt(10)); //charAt(int index);
14 System.out.println(6+"\t"+strbu.delete(3, 9)); //delete(int start, int end);
15 System.out.println(7+"\t"+strbu.insert(5, false)); //insert(int offset, boolean b);
16 System.out.println(8+"\t"+strbu.substring(7)); //substring(int start)
17 System.out.println(9+"\t"+strbu.reverse() ); //reverse()
18
19 }
20
21 }
运行结果
JAVA (StringBuffer/StringBuilder)常用API
标签:api sub src class main div ges bsp index
原文地址:http://www.cnblogs.com/-maji/p/7123248.html