StringBuffer笔试题
package com.sq.sgg;
import org.junit.Test;
public class IDEADebug {
@Test
public void testStringBuffer(){
String str = null;
StringBuffer sb = new StringBuffer();
sb.append(str);
System.out.println(sb.length());// 4
System.out.println(sb);// "null"
StringBuffer sb1 = new StringBuffer(str);//NullPointerException
// 下面这个不执行,上行代码报异常
System.out.println(sb1);
}
}