public Map<Object> map = new HashMap<Object>();
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;
}
}
I have a hashmap, basically Object.getC() 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:
public static void deleteChest() {
for (int i = 0; i < 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);
}
}
}
data hashmap should have the same index number as the map hashmap, so if you're wondering what is it.
Basically, I loop through all data hashmap items (to get the A, B and then match if C is inside the other hashmap (map)).
Now the question time
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).
Object. You won't even know what hit you.Fooinstead