1
您好我试图从地图除去对象和我测试使用断言爪哇断言禁用Map.remove的执行()
// 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);
前述方法上相同的数据进行了测试此操作。为什么Map.remove()不能用于assert?
您是否启用了'assert's? –
确保启用了断言(在启动JVM时提供了'-ea'开关) – aioobe