示例: isEmpty、isNotEmpty 判断 List
import org.apache.commons.collections.MapUtils;
import java.util.HashMap;
import java.util.Map;
public class MapUtilsTest {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
System.out.println(MapUtils.isEmpty(map));
System.out.println(MapUtils.isNotEmpty(map));
}
}
执行结果:
true
false
示例: isEmpty、isNotEmpty 判断 Set
import org.apache.commons.collections.CollectionUtils;
import java.util.HashSet;
import java.util.Set;
public class CollectionUtilsTest {
public static void main(String[] args) {
Set<Long> numSet = new HashSet<>();
System.out.println(CollectionUtils.isEmpty(numSet));
System.out.println(CollectionUtils.isNotEmpty(numSet));
}
}
执行结果:
true
false