Java中判断是否为空
1.字符串是否为空
这里首先要满足是个对象(==null),再对对象调用方法.length或者.equals("")
public static boolean isEmpty(String s) { return s == null || s.length() == 0; } //极简条件写法,把条件写在return后面 //满足s==null||s==xxxx就返回true //不满足就返回false
2.数组是否为空
list.isEmpty();
3.集合是否为空
CollectionUtils.isEmpty(集合);
                    
                
                
            
        
浙公网安备 33010602011771号