title: Java: find empty key in map:
body: <p>I don't know why does not work with me. I have a empty keys in map but I cannot catch them.</p>
  
  <pre><code>Map&lt;String, Long&gt; map = new TreeMap&lt;&gt;();
  
  //put data
  
  map.entrySet().stream().forEach(e -&gt; {
      if (e.getKey().equals("") || e.getKey().equals(" ") || e.getKey() == "" || e.getKey() == " ") {
          map.remove(e.getKey(), e.getValue());
      }
  });
  </code></pre>
  
  <p>Edited:
  I made a test for value:</p>
  
  <pre><code>     map.entrySet().stream() .forEach(e -&gt; {
              if (e.getValue() == 133835) {
              System.out.println("key empty: " + e.getKey().isEmpty());
              System.out.println("key: &gt;" + e.getKey() + "&lt;");
              System.out.println("val: " + e.getValue());
          }
      });
  
      map = map.entrySet().stream().filter(
              p -&gt; !"".equals(p.getKey().trim())).
              collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  
  
  map.entrySet().stream() .forEach(e -&gt; {
      if (e.getValue() == 133835) {
  
          System.out.println("key empty: " + e.getKey().isEmpty());
          System.out.println("key: &gt;" + e.getKey() + "&lt;");
          System.out.println("val: " + e.getValue());
      }
  });
  </code></pre>
  
  <p>the result is:</p>
  
  <pre><code>key empty: false
  key: &gt;‏&lt;
  val: 133835
  key empty: false
  key: &gt;‏&lt;
  val: 133835
  </code></pre>
  
  <p>I think this key is a gost )</p>