package com.letv.test.base;
import java.util.Arrays;
public class StringBuffer {
private char[] value;
private int count;
public StringBuffer() {
value = new char[16];
count = 0;
}
public StringBuffer(String str) {
value = Arrays.copyOf(str.toCharArray(), str.length() + 16);
count = str.length();
}
public synchronized StringBuffer appen(String str) {
if (count + str.length() > value.length) {
value = Arrays.copyOf(value, count + str.length() + 16);
}
System.arraycopy(str.toCharArray(), 0, value, count, str.length());
// str.getChars(0, str.length(), value, count);
count = count + str.length();
return this;
}
}
一步一步行走,做好每一件事情。