Created
May 23, 2018 08:34
-
-
Save JichunMa/13343ab0d09b787f3061ce1e96701ba5 to your computer and use it in GitHub Desktop.
自定义类indexOf规则自实现方方式(修改equals方法时一定要修改hashCode方法)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
AreaBean labelBean = (AreaBean) o; | |
if (label != null ? !label.equals(labelBean.label) : labelBean.label != null) return false; | |
return value != null ? value.equals(labelBean.value) : labelBean.value == null; | |
} | |
@Override | |
public int hashCode() { | |
int result = label != null ? label.hashCode() : 0; | |
result = 31 * result + (value != null ? value.hashCode() : 0); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment