isEmpty ) )方法确定地图是否具有内容,即new是否在分配空间后推送键值对,如果没有内容,则确定为true,否则为false
==null用于确定map是否为空,即new是否分配区域,以及其中的键值对是否无关,如果没有内容,则为true,否则为false
Map map=new HashMapString,String (; 判断在system.out.println(map中是否存在内容:' map.isEmpty ) ); trueSystem.out.println (返回(确定map是否为空: ) map==空); false Map map=new HashMapString,String (返回; map=空; system.out.println (确定map是否为空: ) (map==空); //结果判断truesystem.out.println(map中是否有内容:' map.isEmpty ) ); //nullpointerexceptionmapmap=newhashmapstring,string (; map.put(null,null ); system.out.println (确定map是否为空: ) (map==空); //false system.out.println (判断map中是否有内容:' map.isEmpty ) ); //false