ArrayList<String> al=new ArrayList<String>();
ArrayList<String> a2=new ArrayList<String>();
al.addAll(null);
添加null时会抛出空指针异常 找半天终于找到原回所在
Exception in thread "main" java.lang.NullPointerException
at java.util.ArrayList.addAll(Unknown Source)
at te.te.main(te.java:21)
因为 new NewsHF().addNbs(page, "news_findByPage", 0,this) 会返回空,至少抛出异常
if (runcount == 0) {
try {
//如果addAll()参数为空 会 抛出异常
nbs.addAll(new NewsHF().addNbs(page, "news_findByPage", 0,this));
runcount++; //类新建不了,所以其属性也无法生成
} catch (Exception e) {
nbs=null;
return;
}
}