//方法1
if (list != null && !list.isEmpty()) {
//list不为空
} else {
//list为空
}
//方法2
if (list == null || list.size() == 0) {
//list为空
} else {
//list不为空
}
list!=null:判断是否存在list,null表示这个list不指向任何的东西,如果这时候你调用它的方法,那么就会出现空指针异常。
list.isEmpty():判断list里是否有元素存在
list.size():判断list里有几个元素