List<Integer> actualList=null;
if(matches.size()!=0) {
for (SearchMatchItem item : matches) {
actualList.add(item.getId());
}
}

上面的代码会引发空指针异常,因为list创建的时候没有指向一个引用

改成下面的代码。
List<Integer> actualList=new ArrayList<Integer>();
if(matches.size()!=0) {
for (SearchMatchItem item : matches) {
actualList.add(item.getId());
}
}

相关文章:

  • 2021-11-16
  • 2021-10-06
  • 2021-04-14
  • 2021-10-20
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-08-17
  • 2021-08-23
  • 2021-11-29
相关资源
相似解决方案