Hi i was trying to remove object from Map and i was testing this operation using assert
// definition of map
private Map<String, Map<Long, Object>> groups = new HashMap<String, Map<Long, Object>>();
// this does not remove item from map
assert groups.get("key").remove(id) != null;
// this removes item from map
groups.get("key").remove(id);
aforementioned methods were tested on same data. Why Map.remove() does not work with assert?
assertstatements either execute or not based on how you start the VM. You should not put side-effects in assertions.From section 14.10 of the Java Language Specification:
and in the discussion part of the same section: