判断集合为空方法

 时间:2026-04-23 14:05:01

1、判断列表list为空的方法:

public static boolean isEmptyList(Collection<?> collection) {

        return collection == null || collection.isEmpty();

    }

Collection一个集合框架来的 也是一个集合接口 通过属性isEmpty()来判断有没有数据

2、判断Map为空的方法:

public static boolean isEmptyMap(Map<?, ?> map) {

        return map == null || isEmptyList(map.keySet());

    }

Map 是一个键值对映射的集合接口 通过map.keySet()方法来返回一个set再判断它是否为空

  • IDEA中怎么设置渲染文档注释
  • intellij idea如何设置java代码风格
  • VSCODE-GIT提交authentication failed处理方法
  • Windows下PyQt4的安装
  • 怎么获取配置文件的值
  • 热门搜索
    马尔代夫旅游团报价 旅游作文100字 四川冬季旅游景点 冬季旅游景点排行 3月份去哪里旅游好 欣欣旅游网首页 江门飞扬旅游官网 新疆旅游包车 云南瑞丽旅游 旅游对经济的影响