溫馨提示×

Java的isnull方法有哪些常見用法

小樊
88
2024-08-15 12:54:34
欄目: 編程語言

  1. 判斷對象是否為null:
Object obj = null;
if (Objects.isNull(obj)) {
    System.out.println("對象為空");
}
  1. 判斷字符串是否為null或空字符串:
String str = null;
if (str == null || str.isEmpty()) {
    System.out.println("字符串為空");
}
  1. 判斷集合是否為null或空集合:
List<String> list = null;
if (list == null || list.isEmpty()) {
    System.out.println("集合為空");
}
  1. 判斷數組是否為null或空數組:
String[] array = null;
if (array == null || array.length == 0) {
    System.out.println("數組為空");
}

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女