start = System.currentTimeMillis();
for (int i = 0; i < 9999; i++) {
sb.append("a");
}
end = System.currentTimeMillis();
System.out.println("使用StringBuffer的时间是:" + (end - start) + "毫秒!"); */
public static void getStringBuffer()
{
Long start=0L;
Long end=0L;
static String useStringBuilder(){
StringBuilder builder = new StringBuilder();
for (int i=0; i<9999; ++i){
builder.append("as");
}
return builder.toString();
}
public static void getSbf()
{
StringBuffer sb = new StringBuffer("TestString");
sb.insert(4,false);
System.out.println(sb.toString());
StringBuffer sbs = new StringBuffer();
String user ="test";
String pwd = "123";
sbs.append("select * from userInfo where username=")
.append(user)
.append("and pwd=")
.append(pwd);
System.out.println(sbs.toString());
StringBuffer sbss = new StringBuffer("Test");
sbss. deleteCharAt(1);
System.out.println(sbss);