b[0]里是空的。null调用方法就会产生空指向异常。
引用类型的变量默认值是null
StringBuffer[] b = new StringBuffer[]{" "," "," "," "," "}
初始化一下,为五个空字符。空字符“ ” 调用append()不会有NullPointerException
StringBuffer[] b = new StringBuffer[5];
b[0] = new StringBuffer();//加上这一句。你只是new初始化了数组,没有实例化数组里的对象。
b[0].append(true);
System.out.println("b[0]="+b[0]);
StringBuffer[] b = new StringBuffer[5];
b[0] = new StringBuffer();
b[0].append(true);
StringBuffer[] b = new StringBuffer[5];?你定义这个干吗?StringBuffer s = new StringBuffer(5);
s.append(true);