java判断集合list是否为空]
一种为:
if(list!=null && list.size()>=0){
//判断list是否为空,且list集合中包含的元素个数小于等于0个
}
isEmpty()判断list集合有没有元素,如果有元素返回false,没有返回true
一种为:
if(list.isEmpty()){//如果为空,则返回null
return null;//因为list集合里没有元素时,返回的是[]不是null
}else{
return lsit;//不为空,返回list集合
}