title: Java removing object from hashmap
body: <pre><code>public Map&lt;Object&gt; map = new HashMap&lt;Object&gt;();
  
  
  map.add(new Object ("a", "b"));
  
  
  public class Object {
  
      private String a;
      private String b;
      private String c;
  
      public Object(String a, String b) {
          this.a = a;
          this.a = b;
          this.c = "" + a + b + "";
      }
  
      public String getA() {
          return a;
      }
  
      public String getB() {
          return b;
      }
  
      public String getC() {
          return c;
      }   
  }   
  </code></pre>
  
  <p>I have a hashmap, basically <code>Object.getC()</code> should be a + b in a string.
  and in some other class, I need to get the c value and if that hashmap collection index has the exact same c value, it will delete the index:</p>
  
  <pre><code>public static void deleteChest() {
      for (int i = 0; i &lt; data.size(); i++) {
          if (data.get(i).getItems().length == 0) {
              Object c = new Object(data.get(i).getA(), data.get(i).getB());
              map.remove(c);
          }
      }
  }
  </code></pre>
  
  <p>data hashmap should have the same index number as the map hashmap, so if you're wondering what is it.</p>
  
  <p>Basically, I loop through all data hashmap items (to get the A, B and then match if C is inside the other hashmap (map)).</p>
  
  <p><strong>Now the question time</strong></p>
  
  <p>How can I check if an object is contained (exists) or delete it (not by index, but by key)? How can I do this (Example above).</p>