1 public class StringBuffer {
5 // private static final int DEFAULTSIZE=16;
7 public StringBuffer(String str) {
8 value=new char[str.count+16];//16 is DEFAULTSIZE
11 for(int i=0;i<count;i++)
12 value[i]=str.value[i+str.offset];
19 public int capacity() {
23 public char charAt(int x) {
24 return value[x+offset];
27 public void append(String s) {
28 if ((s.count+count+offset)>value.length) {
30 char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
31 for(int i=0;i<count;i++)
32 newvalue[i]=value[i+offset];
33 for(int i=0;i<s.count;i++)
34 newvalue[i+count]=s.value[i+s.offset];
39 for(int i=0;i<s.count;i++) {
40 value[i+count+offset]=s.value[i+s.offset];
46 public void append(StringBuffer s) {
47 if ((s.count+count+offset)>value.length) {
49 char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
50 for(int i=0;i<count;i++)
51 newvalue[i]=value[i+offset];
52 for(int i=0;i<s.count;i++)
53 newvalue[i+count]=s.value[i+s.offset];
58 for(int i=0;i<s.count;i++) {
59 value[i+count+offset]=s.value[i+s.offset];
65 public String toString() {
66 return new String(this);