自定义实体类
/**
* @Author:
* @Description: 自定义类
* 使用@Data注解会使类自动重写hashcode()和equals()方法
* @Date:
*/
//@Data
public class Key{
private Integer id;
public Key(Integer id) {
this.id = id;
}
/*@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Key key = (Key) o;
return Objects.equals(id, key.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}*/
}
/**
* @Author:
* @Description: 通过hashMap的key存放自定义对象,来理解hashcode()和equals()
* @Date:
*/
public class WithoutHashCode {
public static void main