Object, list, array, string to determine whether it is empty


1. Determine whether the object, String is empty

Use the judgment method of the tool class StringUtils

StringUtils.isEmpty(CharSequence cs); 
//org.apache.commons.lang3包下的StringUtils类,判断是否为空的方法参数是字符序列类,也就是String类型

StringUtils.isEmpty(Object str); 
//而org.springframework.util包下的参数是Object类,也就是不仅仅能判断String类型,还能判断其他类型,比如Long等类型。
2. Determine if the array is empty
arrylist.isEmpty(); //返回boolean类型。

3. Determine if the list is empty

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





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325901921&siteId=291194637