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);//
}
Stringbuffer添加null会怎样
最新推荐文章于 2023-05-09 21:42:34 发布