js中对map的非空判断,java中对map的非空判断

js函数中判断map是否为空
if (JSON.stringify(map) != JSON.stringify({}))

Java中判断map是否为空
1、map.isEmpty
2、map == null 是指没有引用的对象。
  map.size() == 0 指map中没有元素。是一个空的集合。
  要判断map是空的。要先判断是不是null 再看size。
3. 工具类,apache common或者spring都提供CollectionUtils.isEmpty(map.get(a))

猜你喜欢

转载自blog.csdn.net/weixin_37701177/article/details/83929006
今日推荐