Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java中检查树映射是否为空_Java - Fatal编程技术网

如何在Java中检查树映射是否为空

如何在Java中检查树映射是否为空,java,Java,有没有什么方法可以让我检查一下树图是否为空 如果树映射为空,则我的代码永远不会进入以下for循环 for (Map.Entry<BigInteger, ArrayList<BigInteger>> entry : myMap.entrySet()) { if (entry.getKey() == FirstModulus) { ArrayList<BigInteger> list = new ArrayList<BigInteger&

有没有什么方法可以让我检查一下树图是否为空

如果树映射为空,则我的代码永远不会进入以下for循环

for (Map.Entry<BigInteger, ArrayList<BigInteger>> entry : myMap.entrySet()) {
      if (entry.getKey() == FirstModulus) {
    ArrayList<BigInteger> list = new ArrayList<BigInteger>();
    list = myMap.get(FirstModulus);
    list.add(gcd);
 } 
      else {
    ArrayList<BigInteger> list = new ArrayList<BigInteger>();
    list.add(gcd);
    myMap.put(FirstModulus, list);
        }
}
for(Map.Entry:myMap.entrySet()){
if(entry.getKey()==firstmodule){
ArrayList=新建ArrayList();
list=myMap.get(firstmodule);
添加列表(gcd);
} 
否则{
ArrayList=新建ArrayList();
添加列表(gcd);
myMap.put(第一个模数,列表);
}
}

TreeMap
扩展并因此继承其所有定义的方法。您不会在
TreeMap
文档中看到
isEmpty()
,因为它是在其父类中定义的,并且没有必要重写它,因为可以使用相同的方法来确定映射是否为空。

是:
myMap.isEmpty()
。请阅读!在地图上迭代时,要小心添加到地图上。。。
myMap.isEmpty()