阅读量:0
- 判断对象是否为null:
Object obj = null; if (Objects.isNull(obj)) { System.out.println("对象为空"); }
- 判断字符串是否为null或空字符串:
String str = null; if (str == null || str.isEmpty()) { System.out.println("字符串为空"); }
- 判断集合是否为null或空集合:
List<String> list = null; if (list == null || list.isEmpty()) { System.out.println("集合为空"); }
- 判断数组是否为null或空数组:
String[] array = null; if (array == null || array.length == 0) { System.out.println("数组为空"); }