1 public class StringBuffer {
4 // private static final int DEFAULTSIZE=16;
6 public StringBuffer(String str) {
7 value=new char[str.count+16];//16 is DEFAULTSIZE
9 for(int i=0;i<count;i++)
10 value[i]=str.value[i+str.offset];
13 public StringBuffer() {
14 value=new char[16];//16 is DEFAULTSIZE
22 public int capacity() {
26 public char charAt(int x) {
30 public void append(String s) {
31 if ((s.count+count)>value.length) {
33 char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
34 for(int i=0;i<count;i++)
36 for(int i=0;i<s.count;i++)
37 newvalue[i+count]=s.value[i+s.offset];
41 for(int i=0;i<s.count;i++) {
42 value[i+count]=s.value[i+s.offset];
48 public void append(StringBuffer s) {
49 if ((s.count+count)>value.length) {
51 char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
52 for(int i=0;i<count;i++)
54 for(int i=0;i<s.count;i++)
55 newvalue[i+count]=s.value[i];
59 for(int i=0;i<s.count;i++) {
60 value[i+count]=s.value[i];
66 public String toString() {
67 return new String(this);