title: How to check to see if a treemap is empty in Java
body: <p>Is there any way that I can check to see if a tree map is empty or not?</p>
  
  <p>my code never enters to the following for loop if the tree map is empty.</p>
  
  <pre><code>for (Map.Entry&lt;BigInteger, ArrayList&lt;BigInteger&gt;&gt; entry : myMap.entrySet()) {
        if (entry.getKey() == FirstModulus) {
      ArrayList&lt;BigInteger&gt; list = new ArrayList&lt;BigInteger&gt;();
      list = myMap.get(FirstModulus);
      list.add(gcd);
   } 
        else {
      ArrayList&lt;BigInteger&gt; list = new ArrayList&lt;BigInteger&gt;();
      list.add(gcd);
      myMap.put(FirstModulus, list);
          }
  }
  </code></pre>