isEmpty()
public static void main(String[] args){ System.out.println("创建Map集合对象"); Map map = new HashMap(); //定义Map集合对象 System.out.println("Map集合的isEmpty方法返回值是:"+map.isEmpty()); //判断集合是否为空 System.out.println("添加内容到Map集合"); map.put("apple","新鲜的苹果"); //向集合中添加对象 map.put("computer","配置优良的计算机"); map.put("book","堆积成山的图书"); System.out.println("Map集合的isEmpty方法返回值是:"+map.isEmpty()); //判断集合是否为空 }运行结果如下:
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有