Java后端开发(十七)-- Java中对Object、Collection集合、Map集合、数组进行判空
目录
1. Maven坐标
2. Object判空
3. Collection判空
4. Map判空
5. Array判空
1. Maven坐标
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
2. Object判空
import org.apache.commons.lang3.ObjectUtils;
public class ObjectUtilsExample {
public static void main(String[] args) {
// 对 Object 进行判空
Object obj1 = null;
Object obj2 = "";
Object obj3 = "hello";
Ob