search

Home  >  Q&A  >  body text

如图,java 在判断的时候,既然不等于null,为什么还要判断size大于0?不等于null肯定大于0呀?

if (passengerList!=null&&passengerList.size()>0) {

} else {

}

黄舟黄舟2822 days ago1492

reply all(11)I'll reply

  • 怪我咯

    怪我咯2017-04-18 10:15:53

    When list==null, the system reports a null pointer exception when list.size()>0 is executed.

    reply
    0
  • Cancelreply