今天公司安排给页面调试Bug,感觉公司人员写的判断判断List是否为空存在一定的问题,公司判断是list!=null这是完全不对的,这只会判断是否有list对象。如果为空,他也会执行if(list!=null)的方法,违反了开发人员的本意,接下来我举出俩种方法来进行判断都是可以判断的list集合为空问题

if(list != null && list.isEmpty())

else{ 做其他处理}

if(list != null && list.size()!=0)

else{ 做其他处理}

 

相关文章:

  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-11-05
  • 2021-11-17
猜你喜欢
  • 2022-02-06
  • 2022-01-24
  • 2022-01-06
  • 2021-10-07
  • 2022-01-01
  • 2021-11-06
相关资源
相似解决方案