
public void test(){
String str = null;
StringBuffer sb = new StringBuffer();
sb.append(str);//append了四个字母 n u l l
System.out.println(sb.length());//4
System.out.println(sb);//"null"
StringBuffer sb1 = new StringBuffer(str);//抛异常NullPointerException 直接使用了
System.out.println(sb1);//
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)