hashSet 不同对象重复(自用记录) hashSet 判断是否包含相同对象时。 相同对象时: Set.contains();返回true Set.add();返回false 不同对象: 反之 重写对象的hashCode方法,因为判断的是hash值。 @Override public int hashCode() { //根据自己需要判断不同值如id,code,name等 return Objects.hash(id,code,name); }