Java Map. Isempty() method: judge whether the map collection object contains content

isEmpty()

Example

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());  //判断集合是否为空
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>