Null pointer access: The variable condition can only be null at this location。

来源:互联网 发布:福州大学至诚学院网络 编辑:程序博客网 时间:2024/04/29 21:25

Null pointer access: The variable condition can only be null at this location。

报空指针错误,

问题主要原因在于没有初始化


例如:

StringBuffer  condition = null;

condition.append("a");

此时就会报这种错误


修改方法:

StringBuffer  condition = new StringBuffer();

condition.append("a");

此时就是正确的

0 0